Author |
Topic |
|
sfi_dev
Practical
37 Posts |
Posted - 13 Jun 2012 : 03:43:02
|
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
|
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 |
|
|
sfi_dev
Practical
37 Posts |
Posted - 13 Jun 2012 : 11:07:57
|
Legend! works well. Thank-you. Your product is looking really good. A few more tests to go :) |
|
|
|
Topic |
|