ANSI -> UT8 Conversion

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

Moderator: Rathinagiri

User avatar
srvet_claudio
Posts: 2044
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 35 times
Been thanked: 146 times
Contact:

Re: ANSI -> UT8 Conversion

Post by srvet_claudio » Thu Dec 12, 2013 8:08 pm

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: 820
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 117 times
Contact:

Post by mustafa » Thu Dec 12, 2013 8:44 pm

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
Has thanked: 1 time
Been thanked: 2 times

Post by Javier Tovar » Thu Dec 12, 2013 10:00 pm

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: 551
Joined: Mon Oct 01, 2012 12:37 pm
Location: Thessaloniki, Greece
Has thanked: 169 times
Been thanked: 19 times
Contact:

Post by quartz565 » Thu Dec 12, 2013 10:33 pm

thank you my friend !

regards,
Nikos
Best Regards,
Nikos.

os: Windows Server 2012 - 64
hw: HP Server E5606, 2.13GHz, 8.00 GB - Intel Xeon CPU

User avatar
srvet_claudio
Posts: 2044
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 35 times
Been thanked: 146 times
Contact:

Post by srvet_claudio » Fri Dec 13, 2013 2:11 pm

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: 820
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 117 times
Contact:

Post by mustafa » Fri Dec 13, 2013 8:52 pm

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 2227 times

User avatar
esgici
Posts: 4502
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 373 times
Been thanked: 111 times
Contact:

Post by esgici » Sat Dec 14, 2013 12:13 am

Hi All

Notre ami Serge Girard gave some good enhancements : Error-tolerant file delete and rename and a nice background image :arrow:
CFANS2UT8-2.jpg
Screen shoot of ANSI -> UT8 conversion - 2
CFANS2UT8-2.jpg (99.69 KiB) Viewed 2217 times
CFANS2UT8-2(src).zip
Source file of ANSI -> UT8 conversion - 2
(52.6 KiB) Downloaded 157 times
CFANS2UT8-2(exe).zip
Executable of ANSI -> UT8 conversion - 2
(1.16 MiB) Downloaded 131 times
Happy HMG'ing :D
Viva INTERNATIONAL HMG :D

User avatar
srvet_claudio
Posts: 2044
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 35 times
Been thanked: 146 times
Contact:

Post by srvet_claudio » Sat Dec 14, 2013 12:44 am

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
Been thanked: 2 times

Post by dhaine_adp » Sat Dec 14, 2013 5:00 pm

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: 2279
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 535 times
Been thanked: 115 times
Contact:

Post by serge_girard » Wed Dec 18, 2013 6:38 pm

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 189 times

Post Reply