Problem reading Unicode file

HMG Unicode versions 3.1.x related

Moderator: Rathinagiri

User avatar
Clip2Mania
Posts: 95
Joined: Fri Jun 13, 2014 7:16 am
Location: Belgium
Been thanked: 1 time

Re: Problem reading Unicode file

Post by Clip2Mania » Tue Jul 22, 2014 1:02 pm

You are right, my conversion method not convenient to your needs :(
Anyway, thank you very much for willing to investigate. Really appreciate it :!:
Erik

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

Post by esgici » Tue Jul 22, 2014 1:25 pm

Well ...

Would you like try another method ?

Code: Select all

/*
  Convert Unicode 32 string to ANSI 
*/

#include <hmg.ch>

PROCEDURE Main
   cANSI := Uni322ANSI( MEMOREAD( "Chanson_EAC.txt" ) ) 
   MemoWrit( "ChansonANSI.txt", cANSI )
RETURN

FUNCTION Uni322ANSI( cUni32Str )          // Convert Unicode 32 string to ANSI
RETURN ( SUBSTR( STRTRAN( cUni32Str, CHR(0), '' ), 3 ) )
And read "ChansonANSI.txt" by an external ( other than HMG features ) editor.

If OK please inform me : any other ADDITIONAL problem ?
Viva INTERNATIONAL HMG :D

User avatar
Clip2Mania
Posts: 95
Joined: Fri Jun 13, 2014 7:16 am
Location: Belgium
Been thanked: 1 time

Post by Clip2Mania » Tue Jul 22, 2014 3:13 pm

This conversion works perfectly Esgici!
Thanks!
Erik

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

Post by esgici » Tue Jul 22, 2014 7:47 pm

OK .

Yet another suggestion :

Code: Select all

/*
  Convert Unicode 16 string to ANSI 
*/

#include <hmg.ch>

PROCEDURE Main
   cANSI := Uni162ANSI( MEMOREAD( "Chanson_EAC.txt" ) ) 
   MsgBox( HMG_ANSI_TO_UNICODE ( cANSI  ) )  
*  MemoWrit( "ChansonANSI.txt", cANSI )
RETURN

FUNCTION Uni162ANSI( cUni16Str )          // Convert Unicode 16 string to ANSI
RETURN ( SUBSTR( STRTRAN( cUni16Str, CHR(0), '' ), 3 ) )
Viva INTERNATIONAL HMG :D

User avatar
Clip2Mania
Posts: 95
Joined: Fri Jun 13, 2014 7:16 am
Location: Belgium
Been thanked: 1 time

Post by Clip2Mania » Wed Jul 23, 2014 6:32 am

Perfect! Unmistakenly the shortest working conversion in this post! :)
And I learned a lot of new functions which I didn't even knew they were part of Harbour ;)

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

Post by esgici » Wed Jul 23, 2014 10:32 am

Clip2Mania wrote:Perfect! Unmistakenly the shortest working conversion in this post! :)
And I learned a lot of new functions which I didn't even knew they were part of Harbour ;)
I'm glad that you like it :)

IMO still the solution of Dr. Soto is better because mine is empiric ;)

I hope our genius doc will found a solution for unexpected character at end of result string.

By the way, HMG_ANSI_TO_UNICODE() is HMG function (built by Dr. Soto), not Harbour. You would look at 'Unicode' section of HMG help for details and other Unicode info and functions.

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D

Kana
Posts: 27
Joined: Sun Feb 07, 2010 2:48 pm

Post by Kana » Sun Sep 14, 2014 9:04 pm

I have code where I write XML file from DBF with

nHandle := FCreate( xmlfile, 0 ) )
...
FWRITE
...
FClose(

This function save ANSI XML file

I don't want convert file with notepad.exe or notepad++ from ANSI to UTF8
Is it posible to save UTF8 file from code?

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

Post by esgici » Sun Sep 14, 2014 9:31 pm

Kana wrote:I have code where I write XML file from DBF with

nHandle := FCreate( xmlfile, 0 ) )
...
FWRITE
...
FClose(

This function save ANSI XML file

I don't want convert file with notepad.exe or notepad++ from ANSI to UTF8
Is it posible to save UTF8 file from code?
Hi Kana

Last version of an ANSI to UT8 file conversion utility is here.

I haven't any experience on .xml file, so I'm not sure this is convenient for your needs.

Please try and inform us about result.

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D

Javier Tovar
Posts: 1274
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 » Sun Sep 14, 2014 10:24 pm

Gracias Sr. Esgici, no había visto esta aplicación!!! :)

Saludos

Kana
Posts: 27
Joined: Sun Feb 07, 2010 2:48 pm

Post by Kana » Mon Sep 15, 2014 3:30 pm

esgici wrote:
Hi Kana

Last version of an ANSI to UT8 file conversion utility is here.

I haven't any experience on .xml file, so I'm not sure this is convenient for your needs.

Please try and inform us about result.

Happy HMG'ing

I create XML from DBF as txt file with xml extensions so your function (CAF2UT8) work fine.
However, I do not need the conversion of strings in the file, I need only file.

I write CHR(0xEF)+CHR(0xBB)+CHR(0xBF) on top of file with FWRITE and
now I have UTF8 file, and that was what I needed.

Thanks very much!

Post Reply