Hexagora Forum
Hexagora Forum
Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Other hexagora products
 Programs (Programmi)
 [HELP] creating unicode txt files
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sfi_dev
Practical

37 Posts

Posted - 13 Jun 2012 :  03:43:02  Show Profile  Visit sfi_dev's Homepage  Reply with Quote
Hi there,

I am evaluating the writing of unicode text files using clsUniFile.
My code is:
Public Function writefile()
sfile = "c:\test.txt"
Dim oUniFile As New clsUniFile
If oUniFile.st_FileExist(sfile) Then oUniFile.st_RmFile (sfile)
sresult = oUniFile.OpenFileWrite(sfile, True)
oUniFile.WriteUnicodeLine ctlUniTextBoxXP1.Text
oUniFile.CloseFile
end function

If I say put an F in the text box and run the function, I am finding that the file looks ok in notepad but when I open it in Microsoft Word a number of extra characters are added (Y with accents etc) which causes an issue in letter merges and the like.

If I create a unicode text file manually in notepad without using a program and save as unicode format, when I open the file in word there are no additional charcaters, just the F.

Am I doing something wrong here ?

Thank-you.

Julie

s.dav
Site Admin

Italy
3364 Posts

Posted - 13 Jun 2012 :  09:14:41  Show Profile  Visit s.dav's Homepage  Reply with Quote
Julie,

you need, just after having created the file, add the so called BOM (a marker) using the "WriteBOM" function.

So:

- OpenFileWrite
- WriteBOM UTF16
- Write Unicode Lines
- Close

or simply use a generic "st_TextFileToString" for creating text files with a certain encoding...

In this part of code:

If oUniFile.st_FileExist(sfile) Then oUniFile.st_RmFile (sfile)

you can omit the FileExists, if the file doesn't exist the RmFile will return false but doesn't raise an error

so:

oUniFile.st_RmFile sfile

Regards, Davide
Go to Top of Page

sfi_dev
Practical

37 Posts

Posted - 13 Jun 2012 :  11:07:57  Show Profile  Visit sfi_dev's Homepage  Reply with Quote
Legend! works well. Thank-you. Your product is looking really good. A few more tests to go :)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Hexagora Forum © s.dav Go To Top Of Page
Snitz Forums 2000