Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with characters from a different language

Status
Not open for further replies.

bksqlman

Programmer
Sep 28, 2005
2
US
I am having trouble accessing data that is stored in different languages, and wondered if anyone here has an experience.
The data is stored in a SQL Server 2000 table, in a field of type nvarchar.
If I do a SELECT query through SQL Query Analyzer or MS Access, I see the data that is stored there properly. In this case, it is a string of Japanese characters.
What I want to do is write the data out to a text file.
I am creating the file as follows:
Code:
Dim fVTMFile As StreamWriter = File.CreateText("C:\test.txt")
And then I am attempting to write the values I retrive back in a Dataset as follows:
Code:
fVTMFile.WriteLine(MyDataRow2("line_text"))
Finally I flush and close the file as follows:
Code:
fVTMFile.Flush()
fVTMFile.Close()
When I deal with rows that are in the English language, it creates the file successfully.
But when I attempt to do it with rows that contain Japanese characters, I just get weird ASCII characters, not the proper Japanese characters that are stored in the table.
I tried using the StrConv function as such:
Code:
fVTMFile.WriteLine(StrConv(MyDataRow2("line_text"), VbStrConv.Katakana))

or

fVTMFile.WriteLine(StrConv(MyDataRow2("line_text"), VbStrConv.Hiragana))
But that did not work either.

Any ideas on how foreign language characters stored in SQL can be written to a text file in VB.Net 2003 would be appreciated.

Thank you.
 
Try opening the text file with an application that is Unicode aware. Notepad is one, but you might have to give it a little push to recognize the UTF-16 encoding that the text writer uses by default.

Another such is Unipad, which is a Unicode editor (very nice, but a little expensive for what it gives you).

Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top