Page 2 of 3

Re: Problem reading Unicode file

Posted: Tue Jul 22, 2014 1:02 pm
by Clip2Mania
You are right, my conversion method not convenient to your needs :(
Anyway, thank you very much for willing to investigate. Really appreciate it :!:
Erik

Re: Problem reading Unicode file

Posted: Tue Jul 22, 2014 1:25 pm
by esgici
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 ?

Re: Problem reading Unicode file

Posted: Tue Jul 22, 2014 3:13 pm
by Clip2Mania
This conversion works perfectly Esgici!
Thanks!
Erik

Re: Problem reading Unicode file

Posted: Tue Jul 22, 2014 7:47 pm
by esgici
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 ) )

Re: Problem reading Unicode file

Posted: Wed Jul 23, 2014 6:32 am
by Clip2Mania
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 ;)

Re: Problem reading Unicode file

Posted: Wed Jul 23, 2014 10:32 am
by esgici
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

Re: Problem reading Unicode file

Posted: Sun Sep 14, 2014 9:04 pm
by Kana
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?

Re: Problem reading Unicode file

Posted: Sun Sep 14, 2014 9:31 pm
by esgici
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

Re: Problem reading Unicode file

Posted: Sun Sep 14, 2014 10:24 pm
by Javier Tovar
Gracias Sr. Esgici, no había visto esta aplicación!!! :)

Saludos

Re: Problem reading Unicode file

Posted: Mon Sep 15, 2014 3:30 pm
by Kana
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!