UTF8 & MySql are 100% compatible with FWH?

UTF8 & MySql are 100% compatible with FWH?

Postby dutch » Mon May 30, 2016 10:10 am

Dear All,

I'm going to move to MySql and UTF8. Is it 100% compatible with latest FWH 16.04 and xHarbour (or Harbour)?

Thanks for suggestion.
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: UTF8 & MySql are 100% compatible with FWH?

Postby nageswaragunupudi » Mon May 30, 2016 5:18 pm

Yes.
We can also provide support if you are using MySql through ADO.

This is a working sample:
Code: Select all  Expand view
#include "fivewin.ch"
#include "adodef.ch"

static oCn

//----------------------------------------------------------------------------//

function Main()

   local oRs, cSql, aStruct
   local cTable   := "namesutf8"

   FW_SetUnicode( .t. )

   ? "Connecting to MySql Server"
   oCn   := FW_OpenAdoConnection( "MYSQL,localhost,fwh,root,India@1947", .t. )
   if oCn == nil
      ? MsgStop( "Connect Fail" )
      return nil
   endif

   if .not. FW_AdoTableExists( cTable, oCn ) .or. ;
      MsgYesNo( "Recreate table " + cTable )

      TRY
         oCn:Execute( "DROP TABLE " + cTable )
      CATCH
      END

      aStruct  := { ;
         { "code", 'C', 2, 0 }, ;
         { "name", "VARCHAR(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" } }

      FWAdoCreateTable( cTable, aStruct, oCn )

   endif

   oRs   := FW_OpenRecordSet( oCn, cTable )

   XBROWSER oRs FASTEDIT TITLE FWVERSION

   oRs:Close()

   oCn:Close()

return nil

//----------------------------------------------------------------------------//
 


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10625
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: UTF8 & MySql are 100% compatible with FWH?

Postby dutch » Tue May 31, 2016 2:04 am

Thank you so much Mr.Rao for your suggestion. I have a question.

If I need to use Unicode (2bytes), which the character set that FWH support (by FW_SetUnicode( .T. ))
Do I need to convert the database (DBF) to MySql (UCS2)? If so.
How to convert from DBF ANSI (TIS620) to MySql (UCS2 Charset).

I'm not quite sure my understanding now.
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: UTF8 & MySql are 100% compatible with FWH?

Postby nageswaragunupudi » Tue May 31, 2016 2:21 am

If you propose to use xHarbour I suggest you use utf8 encoding of MySql.
Porting from DBF to MySql should be simple. Read from dbf and write to MySql table. Suggest creating MySql tables in the manner I suggested in the above example.

I understand TIS620 is specific to Thai. In the present days better to use more generic Unicode which makes the application to deal with any language in the world at the same time.

If you like, we can support conversion of some dbf tables as samples.

I suggest you try the sample I posted above. You can easily enter and edit Thai names in the table.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10625
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: UTF8 & MySql are 100% compatible with FWH?

Postby dutch » Tue May 31, 2016 3:10 am

Thank you Mr.Rao,

What is different between CHARSET=utf8 and utf8mb4?

I use "DEFAULT CHARSET=utf8" when create table. It show Thai Character in "MySql Query Browser" program correctly.

I use FW_SETUNICODE( .T. ) in the begining of the program but it show in "?" instead.

How can show UTF8 database in FWH? .or. What I do wrong?
Image
image upload no size limit
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: UTF8 & MySql are 100% compatible with FWH?

Postby nageswaragunupudi » Tue May 31, 2016 4:51 am

In UTF8, one character can be represented by 1 to 3 bytes. Maximum is 3 bytes. But some characters in some complex languages can not be accommodated even in 3 bytes. For this purpose there is an extended version of UTF8 known as utf8mb4 or utf8ex, etc. To the best of my knowledge, for Thai language normal utf8 should be enough.

In your case, by default you should be able to browse Thai language. But I can not immediately comment unless I know more.

First I request you to test the sample (without any changes) I provided and let me know if it is working. Based on that I can understand what must be the reason and advise you further.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10625
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: UTF8 & MySql are 100% compatible with FWH?

Postby dutch » Tue May 31, 2016 6:09 am

Dear Mr.Rao,

I tested with your code, it can show correctly with ADO.
But I use TMySql or TDolphin to Fetch the datas from MySql and use the same data and same code of yours. It doesn't show correctly.

Do you know what is my problem?
Code: Select all  Expand view
#include 'fivewin.ch'
#include "xbrowse.ch"

Static oServer

function main
   FW_SetUnicode( .T. )
   oServer:= TMYSQLSERVER():new( 'localhost', 'root', 'nimda', 3306)
   IF oserver:lError
      MSGALERT( "There was error connecting will check if there is connection to the server or user / password is incorrected")
      Return Nil
   Endif
   oServer:selectdb("easyfo")
   ShowxBr( oServer, 'namesutf8' )
return nil

*-----------------------*
Procedure ShowxBr( oServer, cTable )
local oqry, oDlg, oBrw

   oqry:=oServer:Query( "SELECT * FROM "+lower(cTable) )    
   IF oqry:lError
      ? "It could not open the database  "
      Return
   endif
   oqry:end()

   XBROWSER oqry FASTEDIT TITLE FWVERSION

return nil

Image
image hosting over 10mb
Thank you so much in advance,
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: UTF8 & MySql are 100% compatible with FWH?

Postby nageswaragunupudi » Tue May 31, 2016 6:17 am

If you insist on using TMySql or TDolphin, you need to ask their authors to provide Unicode compatibility. I understand they do not even support DateTime valtype, though I am not sure.

As far as FWH is concerned it works well with Unicode and we can offer support if you choose to use ADO. Obviously your problem has nothing to do with FWH.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10625
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: UTF8 & MySql are 100% compatible with FWH?

Postby dutch » Tue May 31, 2016 6:41 am

Dear Mr.Rao,

It means TMySql or TDolphin do not support MySql with CHARSET=UTF8.

Thank you so much for your time to check this case.
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: UTF8 & MySql are 100% compatible with FWH?

Postby cnavarro » Tue May 31, 2016 6:45 am

I not use TMySql, or TDolphin, but
You are tested with HB_SETCODEPAGE( "UTF8" ) ?
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: UTF8 & MySql are 100% compatible with FWH?

Postby nageswaragunupudi » Tue May 31, 2016 6:58 am

cnavarro wrote:I not use TMySql, or TDolphin, but
You are tested with HB_SETCODEPAGE( "UTF8" ) ?


Your suggestion is only for Harbour but not for xHarbour I mean SETCODEPAGE( "UTF8" ).

Still please let us know if you used successfully Unicode with TMysql or TDolphin.

In any case, I shall test with TDolphin in a few days and get back to you.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10625
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: UTF8 & MySql are 100% compatible with FWH?

Postby nageswaragunupudi » Tue May 31, 2016 9:01 am

Just started testing with TDolphin.
Small test with harbour as I could find dolphin.lib ready with fwh.

Code: Select all  Expand view
#include "FiveWin.Ch"
#include "tdolphin.ch"

static cpw := "xxxxxxx"
//----------------------------------------------------------------------------//

function Main()

   local oDlg, oBrw, oFont
   local oQry

   FW_SetUnicode( .T. )

   db()
   oQry  := TDolphinQry():New( "SELECT * FROM namesutf8", db() )

   DEFINE FONT oFont NAME "Segoe UI" SIZE 0,-16

   DEFINE DIALOG oDlg SIZE 500,300 PIXEL TITLE FWVERSION + " : TDolphin" ;
      FONT oFont

   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      DATASOURCE oQry ;
      COLUMNS "code", "name" ;
      CELL LINES NOBORDER AUTOSORT FASTEDIT

   WITH OBJECT oBrw
      :nEditTypes := EDIT_GET
      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

   db():End()

return (0)

//----------------------------------------------------------------------------//

function db()

   static oCn

   if oCn == nil
      CONNECT oCn ;
         HOST "localhost" USER "root" PASSWORD cpw DATABASE "fwh"
   endif

return oCn

//----------------------------------------------------------------------------//
 


Image

We can expect the same results with xHarbour too. I could edit unicode text in the cell and save it too.
So we can use TDolphin for Unicode. Probably TMySql also may behave the same way.

In case you created the table in my first sample, please try this sample too. You have the include file in fwh\include and dolphin.lib in fwh\lib folder for Harbour.

I shall do some more tests and get back.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10625
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: UTF8 & MySql are 100% compatible with FWH?

Postby dutch » Wed Jun 01, 2016 12:11 am

Dear Mr.Rao & Cristobal,

I've got the same. I try the DATA of Mr.Rao but it is not successful as picture.
I use xharbour 1.2.3 & FWH 1509.
Does FWH1509 support UTF8?
Image
uploading pictures

This is Mr.Rao sample.
Image
screen shot on pc
Code: Select all  Expand view
#include 'fivewin.ch'
#include "xbrowse.ch"
#include 'Tdolphin.ch'

Static oServer, oFont

function main
   
   HB_SETCODEPAGE( "UTF8" )
   FW_SetUnicode( .T. )

   oServer:= ConnectMySql( 'localhost', 'root', 'nimda', 3306, 0, 'easyfo')
   IF oserver:lError
      MSGALERT( "There was error connecting will check if there is connection to the server or user / password is incorrected")
      Return Nil
   Endif
   ShowxBr( oServer, 'namesutf8' )
return nil

*-----------------------*
Procedure ShowxBr( oServer, cTable )
local oqry, oDlg, oBrw, oErr
   
   TRY
   oqry:=oServer:Query( "SELECT * FROM "+lower(cTable) )    
   CATCH oErr
      ? "It could not open the database  "
      Return
   END TRY
   
   DEFINE FONT oFont NAME "Segoe UI" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE 500, 300 PIXEL TITLE FWVERSION FONT oFont
   @ 0, 0 XBROWSE oBrw SIZE -10, -10 PIXEL OF oDlg ;
          DATASOURCE oqry ;
      COLUMNS "Code", "Name" ;
          FASTEDIT NOBORDER LINES CELL AUTOSORT
   
   oBrw:CreateFromCode()
//   oDlg:oClient := oBrw
   ACTIVATE DIALOG oDlg CENTER


//   XBROWSER oqry FASTEDIT TITLE FWVERSION  

   oqry:end()
   
return nil

*-------------------------------------------------------------------------*
Function ConnectMySql( cServer, cUser, cPassword, nPort, nFlags, cDBName )
local oSvr, oErr
   TRY
      CONNECT oSvr HOST cServer ;
                      USER cUser ;
                      PASSWORD cPassword ;
                      PORT nPort ;
                      FLAGS nFlags;
                      DATABASE cDBName
                               
   CATCH oErr
   
        MsgStop( hb_dumpvar( oErr ) )
     
        RETURN NIL
   END
 
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: UTF8 & MySql are 100% compatible with FWH?

Postby nageswaragunupudi » Wed Jun 01, 2016 2:22 am

FWH15.09 supports Unicode. There were improvements in subsequent versions, but FWH 1509 should work in this case. Here it is working for me with FWH1509 and Harbour.
Image

We need to see why it did not work there for you.

Note:
HB_SETCODEPAGE( "UTF8" ) does not make any difference in xHarbour.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10625
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: UTF8 & MySql are 100% compatible with FWH?

Postby dutch » Wed Jun 01, 2016 10:01 am

Dear Mr.Rao,

I try Harbour & TDolphin as picture but I got 2 errors. How do I fix it?
Image
upload images free

Thanks in advance.
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 24 guests