B4J Question What is lastest version of jStringUtils ?

pmt

Member
Licensed User
I have problem about UTF8 when use SaveCSV/SaveCSV2.

After save CSV file I try to open with Notepad , Excel , OpenOffice.

Before add BOM:
-Open with Notepad .... Read Correct.
-Open with Excel .... Read Not Correct !!!.
-Open with OpenOffice.... Read Not Correct !!!.

After add BOM:
-Open with Notepad .... Read Correct.
-Open with Excel .... Read Correct.
-Open with OpenOffice.... Read Not Correct !!!.


I use jStringUtils version 1.00 and B4J 5.90

I tried to search new version , but I can not find.

Is there a new version save CSV correct for all applications which support CSV?


Regards,
PMT
 
I have problem about UTF8 when use SaveCSV/SaveCSV2.

After save CSV file I try to open with Notepad , Excel , OpenOffice.

Before add BOM:
-Open with Notepad .... Read Correct.
-Open with Excel .... Read Not Correct !!!.
-Open with OpenOffice.... Read Not Correct !!!.

After add BOM:
-Open with Notepad .... Read Correct.
-Open with Excel .... Read Correct.
-Open with OpenOffice.... Read Not Correct !!!.


I use jStringUtils version 1.00 and B4J 5.90

I tried to search new version , but I can not find.

Is there a new version save CSV correct for all applications which support CSV?


Regards,
PMT
Current version of B4J is 6.30, so you are a bit behind.... JStringUtils, if I remember correctly, is part of the core libs... so with the latest IDE all core kind are uptodate
 
Upvote 0
It has nothing to do with jStringUtils version.

StringUtils.SaveCSV creates UTF8 encoded CSV files. Without BOM. If you need other encoding then it will require some very simple work.

Thank you for your reply .

My data is Asian Language after I use StringUtils.SaveCSV I can't correctly read it.

( I tried Excel and save my data as CSV and read for all programs , all read correctly as original data. )

I found solution here:

Code: Copy
StringUtils.SaveCSV(...)
Dim s As String = File.ReadString (...)' read the file
s = Chr(0xFEFF) & s 'add BOM
File.WriteString(..., s)

But some programs can correctly read , some programs can't .

How to fix it ?

Regards,
PMT
 
Upvote 0
How to save csv as ANSI (windows-874 , iso-8859-11 , tis-620)

I try like this ( B4J).

Code: Copy
su.SaveCSV2(File.DirApp, fileName, ",", Items, headers)
Dim s As String = File.ReadString(File.DirApp, fileName)
Dim data() As Byte = s.GetBytes("windows-874")   ' and I also try iso-8859-11 , tis-620
s= BytesToString(data,0,data.Length,"windows-874")

's = Chr(0xFEFF) & s 'Add BOM
File.WriteString(File.DirApp, fileName, s)

It' s not work , it 's still encode as UTF-8.

Regards,
PMT
 
Upvote 0
File.WriteString uses UTF8 encoding to encode the text.

Code: Copy
Dim data() As Byte = ...
File.WriteBytes(File.DirApp, filename, data) 'Don't use File.DirApp if you plan to create an installer. Use File.DirData instead

Another option is to use TextWriter. File.WriteBytes is neater.

I can not tried this
Code: Copy
File.WriteBytes(File.DirApp ,  fileName,data)

Because I use jRandomAccessFile (2.30) and no function File.WriteBytes(...).

So I tried this
Code: Copy
Dim out As OutputStream = File.OpenOutput(File.DirApp, fileName, False)
            out.WriteBytes(data, 0, data.Length)
            out.Close

Now it's work.

Thanks you.
PMT
 
Upvote 0

Similar Threads

Back
Top