ANSI -> UT8 Conversion

Utilities like DBU, Make, IDE written in HMG/ used to create HMG based applications

Moderator: Rathinagiri

User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: ANSI -> UT8 Conversion

Post by srvet_claudio »

mustafa wrote:Hola Mol
Curiosamente si pones:
@ 210,100 LABEL Label_c VALUE "ampersand "+ chr(038) WIDTH 290 HEIGHT 25 FONT "ARIAL" SIZE 14
solo sale ------------> ampersand , no sale simbolo &
pero si pones:
@ 310,100 LABEL Label_d VALUE "ampersand "+"&" + chr(038) WIDTH 290 HEIGHT 25 FONT "ARIAL" SIZE 14
sale correcto --------> ampersand &
Guardado fichero con UTF-8
Curioso
Mustafa
*-------------------------------------------------*
Hello Mol
Interestingly if you put:
@ 210,100 Label_c LABEL VALUE "ampersand" + chr (038) 290 HEIGHT 25 WIDTH FONT "ARIAL" SIZE 14
only goes ------------> ampersand, no sale symbol &
but if you put:
@ 310.100 Label_d LABEL VALUE "ampersand" + "&" + chr (038) 290 HEIGHT 25 WIDTH FONT "ARIAL" SIZE 14
goes right ampersand &
save file with UTF-8
curious
Mustafa
Amigo Mustafa,
Para mostrar caracteres en Unicode debes reemplar CHR() y ASC() por:

Code: Select all

SET CODEPAGE TO UNICODE
msgdebug ( nCode:=HB_UCODE("&") , HB_UCHAR(nCode) )
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: ANSI -> UT8 Conversion

Post by mustafa »

Hola amigo Claudio, como estas ?
gracias por el ejemplo, pero no entiendo mucho la respuesta como aplico
tu sample al Label ? le pongo
SET CODEPAGE TO UNICODE
nCode:=HB_UCODE("&") , HB_UCHAR(nCode)
@ 310.100 Label_d LABEL VALUE nCode 290 HEIGHT 25 WIDTH FONT "ARIAL" SIZE 14
me da Error y otra cosa que no entiendo, el fichero lo guardo con UTF-8 ? porque si
guardo con Unicode me da Error
Mustafa
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: ANSI -> UT8 Conversion

Post by Javier Tovar »

Hola mustafa,

Si no me equivoco lo que quiere decir el Amigo Claudio es emplear las funciones que el dice arriba como se hace con:

Code: Select all

Examples

     .  These examples illustrate CHR() with various arguments:

        ? CHR(72)                    // Result: H
        ? CHR(ASC("A") + 32)         // Result: a
        ? CHR(7)                     // Result: bell sounds

     .  These lines of code show the difference between a null string
        and the null character:

        ? LEN("")                   // Result: 0
        ? LEN(CHR(0))               // Result: 1
/////////////////////////////////////////////////////////////////////////////////////////

Examples

     .  These examples illustrate various results of ASC():

        ? ASC("A")                     // Result: 65
        ? ASC("Apple")                 // Result: 65
        ? ASC("a")                     // Result: 97
        ? ASC("Z") - ASC("A")          // Result: 25
        ? ASC("")                      // Result: 0

Siendo estas funciones reciprocas.

Saludos
User avatar
quartz565
Posts: 667
Joined: Mon Oct 01, 2012 12:37 pm
Location: Thessaloniki, Greece
Contact:

Re: ANSI -> UT8 Conversion

Post by quartz565 »

thank you my friend !

regards,
Nikos
Best Regards,
Nikos.

os: Windows Server 2019 - 64
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: ANSI -> UT8 Conversion

Post by srvet_claudio »

mustafa wrote:Hola amigo Claudio, como estas ?
gracias por el ejemplo, pero no entiendo mucho la respuesta como aplico
tu sample al Label ? le pongo
SET CODEPAGE TO UNICODE
nCode:=HB_UCODE("&") , HB_UCHAR(nCode)
@ 310.100 Label_d LABEL VALUE nCode 290 HEIGHT 25 WIDTH FONT "ARIAL" SIZE 14
me da Error y otra cosa que no entiendo, el fichero lo guardo con UTF-8 ? porque si
guardo con Unicode me da Error
Mustafa
Hola Mustafa, yo me encuentro bien, espero que tu y tu familia también.

Code: Select all

SET CODEPAGE TO UNICODE

nCode:=HB_UCODE("&") // Devuelve el código (numero) Unicode del caracter "&" 

@ 210,100 Label_c LABEL VALUE "ampersand" + HB_UCHAR(nCode) 290 HEIGHT 25 WIDTH FONT "ARIAL" SIZE 14  
HB_UCODE() --> equivale a ASC() en ANSI
HB_UCHAR() --> equivale a CHR() en ANSI

Sí, el fichero lo guardas como UTF-8.
Un abrazo,
Claudio.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: ANSI -> UT8 Conversion

Post by mustafa »

Hola Claudio
Intento hacerlo como tu me indicas pero al complilar no sale
el simbolo "&", no creo que sea no trabajar con el IDE,
trabajo con Build.bat --- > c:\hmg.3.2\build.bat Main %*
el codigo fuente es:

#include "hmg.ch"
Function Main
SET CODEPAGE TO UNICODE
DEFINE WINDOW Form_1;
AT 0,0 ;
WIDTH 400 ;
HEIGHT 400 ;
TITLE '' ;
MAIN

@ 050,100 LABEL Label_a VALUE "ampersand Antiguo "+"&" + chr(038) WIDTH 290 HEIGHT 25 FONT "ARIAL" SIZE 14
*** Para mostrar caracteres en Unicode debes reemplazar CHR() y ASC() por:
*----------------------------------------------------------------------*
SET CODEPAGE TO UNICODE
msgdebug ( nCode:=HB_UCODE("&") , HB_UCHAR(nCode)
*-----------------------------------------------------------------------*
SET CODEPAGE TO UNICODE
nCode:=HB_UCODE("&") // Devuelve el código (numero) Unicode del caracter "&"
@ 080,100 LABEL Label_b VALUE "ampersand Claudio " + HB_UCHAR(nCode) WIDTH 290 HEIGHT 25 FONT "ARIAL" SIZE 14
@ 110,100 LABEL Label_c VALUE "ampersand Mustafa " + "&" + HB_UCHAR(nCode) WIDTH 290 HEIGHT 25 FONT "ARIAL" SIZE 14
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return Nil

Guardado como UTF-8 con el Notepad
Un Saludo
Mustafa
Attachments
screenshot.jpg
screenshot.jpg (25.26 KiB) Viewed 4823 times
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: ANSI -> UT8 Conversion

Post by esgici »

Hi All

Notre ami Serge Girard gave some good enhancements : Error-tolerant file delete and rename and a nice background image :arrow:
Screen shoot of ANSI -> UT8 conversion - 2
Screen shoot of ANSI -> UT8 conversion - 2
CFANS2UT8-2.jpg (99.69 KiB) Viewed 4813 times
CFANS2UT8-2(src).zip
Source file of ANSI -> UT8 conversion - 2
(52.6 KiB) Downloaded 316 times
CFANS2UT8-2(exe).zip
Executable of ANSI -> UT8 conversion - 2
(1.16 MiB) Downloaded 287 times
Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: ANSI -> UT8 Conversion

Post by srvet_claudio »

mustafa wrote: Hola Claudio
Intento hacerlo como tu me indicas pero al complilar no sale
el simbolo "&", no creo que sea no trabajar con el IDE,
trabajo con Build.bat --- > c:\hmg.3.2\build.bat Main %*
el codigo fuente es:

#include "hmg.ch"
Function Main
SET CODEPAGE TO UNICODE
DEFINE WINDOW Form_1;
AT 0,0 ;
WIDTH 400 ;
HEIGHT 400 ;
TITLE '' ;
MAIN

@ 050,100 LABEL Label_a VALUE "ampersand Antiguo "+"&" + chr(038) WIDTH 290 HEIGHT 25 FONT "ARIAL" SIZE 14
*** Para mostrar caracteres en Unicode debes reemplazar CHR() y ASC() por:
*----------------------------------------------------------------------*
SET CODEPAGE TO UNICODE
msgdebug ( nCode:=HB_UCODE("&") , HB_UCHAR(nCode)
*-----------------------------------------------------------------------*
SET CODEPAGE TO UNICODE
nCode:=HB_UCODE("&") // Devuelve el código (numero) Unicode del caracter "&"
@ 080,100 LABEL Label_b VALUE "ampersand Claudio " + HB_UCHAR(nCode) WIDTH 290 HEIGHT 25 FONT "ARIAL" SIZE 14
@ 110,100 LABEL Label_c VALUE "ampersand Mustafa " + "&" + HB_UCHAR(nCode) WIDTH 290 HEIGHT 25 FONT "ARIAL" SIZE 14
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return Nil

Guardado como UTF-8 con el Notepad
Un Saludo
Mustafa
Mustafa aquí esta la solución: viewtopic.php?p=31415#p31415
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines

Re: ANSI -> UT8 Conversion

Post by dhaine_adp »

Hi all,

There is also a UnicodeLib contributed by Mr. Kevin Carmody on http://www/hmgextended.com" onclick="window.open(this.href);return false; or from here:
http://groups.yahoo.com/group/harbourminigui/" onclick="window.open(this.href);return false;

FYI. It is well documented but haven't try to use the lib myself.

Regards,

Danny
Regards,

Danny
Manila, Philippines
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: ANSI -> UT8 Conversion

Post by serge_girard »

Hello All !

I upgraded the idea of Esgici and made a little tool that do the real conversion to your program: replace all occurences of LEN() with HMG_LEN(), ASC() with HB_UCODE(), etc...

Maybe the UNICODE experts can take a look at it and tell me if it is correct.

See attachtment and enjoy!

Serge
Attachments
CFANS2UT8.rar
(819.54 KiB) Downloaded 366 times
There's nothing you can do that can't be done...
Post Reply