Problem reading Unicode file

HMG Unicode versions 3.1.x related

Moderator: Rathinagiri

User avatar
Clip2Mania
Posts: 99
Joined: Fri Jun 13, 2014 7:16 am
Location: Belgium

Re: Problem reading Unicode file

Post 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
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Problem reading Unicode file

Post 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 ?
Viva INTERNATIONAL HMG :D
User avatar
Clip2Mania
Posts: 99
Joined: Fri Jun 13, 2014 7:16 am
Location: Belgium

Re: Problem reading Unicode file

Post by Clip2Mania »

This conversion works perfectly Esgici!
Thanks!
Erik
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Problem reading Unicode file

Post 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 ) )
Viva INTERNATIONAL HMG :D
User avatar
Clip2Mania
Posts: 99
Joined: Fri Jun 13, 2014 7:16 am
Location: Belgium

Re: Problem reading Unicode file

Post 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 ;)
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Problem reading Unicode file

Post 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
Viva INTERNATIONAL HMG :D
Kana
Posts: 27
Joined: Sun Feb 07, 2010 2:48 pm

Re: Problem reading Unicode file

Post 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?
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Problem reading Unicode file

Post 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
Viva INTERNATIONAL HMG :D
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Problem reading Unicode file

Post by Javier Tovar »

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

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

Re: Problem reading Unicode file

Post 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!
Post Reply