Character conversion from a .txt file

Q

Quan

Hi,

We have a SQL Server DB that currently holds Big5 encoded text
for example: ¡u¤ì§÷«Ø¿v¡v
I have no problem displaying this text in a web browser. The
characters show up fine.

The problem is, I have a text file where I'm using the vb streamreader
class to read in data. I've been trying to convert the input from the
file (which I belive is in UTF-8, correct me if I'm wrong please) into
the same Big5 encoding shown above in order to store it into the DB.

A sample of the data from the text file looks like this:
è¿"回到åª'ä½"中心 (I'm not sure if this will display properly in
the news group).

If anyone has any suggestions or ideas, any help would greatly be
appreciated. Thanks.
 
J

Jon Skeet [C# MVP]

Quan said:
We have a SQL Server DB that currently holds Big5 encoded text
for example: ¡u¤ì§÷«Ø¿v¡v
I have no problem displaying this text in a web browser. The
characters show up fine.

The problem is, I have a text file where I'm using the vb streamreader
class to read in data. I've been trying to convert the input from the
file (which I belive is in UTF-8, correct me if I'm wrong please) into
the same Big5 encoding shown above in order to store it into the DB.

We can't know for sure what's in your text file, or what encoding it
is. If you post the bytes from the file (rather than posting it as
characters) we can tell whether it *might* be UTF-8, especially if you
know what the text is meant to look like and describe it for us.
 
Q

Quan

Thanks for the fast reply Jon,

I'm a little new to this so bear with me a little. I was just curious
how I would post the bytes from text file to the newsgroup?
 
J

Jon Skeet [C# MVP]

Quan said:
Thanks for the fast reply Jon,

I'm a little new to this so bear with me a little. I was just curious
how I would post the bytes from text file to the newsgroup?

Dump them as hex, eg

05 6d 7d 1f 80

etc
 
Q

Quan

Actually, sorry, let me simplify the problem a little. When debugging,
this is what my SQL statement looks like when watching the variables
(vb.net).

INSERT INTO blah (blah2) VALUES
('外層面板中的纖維&#2646
3;,像合板一樣沿著&#2640
8;板長軸作定向,因&#3278
0;沿著長軸的強度要&#2282
3;於窄軸')

This doesn't work because all I get in SQL Server is a bunch of
???????????

What I want it to do is insert its big5 encoded string into the
database.

INSERT INTO blah (blah2) VALUES
('¥~¼h­±ªO¤¤ªºÅÖºû§ô¡A¹³¦XªO¤@¼ËªuµÛ¤ìªOªø¶b§@©w¦V¡A¦]¦ÓªuµÛªø¶bªº±j«×­n
¤j©ó¯¶¶b¡C')

Is it even feasible to do even do this?

Thanks in advance.
 
J

Jon Skeet [C# MVP]

Quan said:
Actually, sorry, let me simplify the problem a little. When debugging,
this is what my SQL statement looks like when watching the variables
(vb.net).

INSERT INTO blah (blah2) VALUES
('外層面板中的纖維&#2646
3;,像合板一樣沿著&#2640
8;板長軸作定向,因&#3278
0;沿著長軸的強度要&#2282
3;於窄軸')

This doesn't work because all I get in SQL Server is a bunch of
???????????

What I want it to do is insert its big5 encoded string into the
database.

INSERT INTO blah (blah2) VALUES
('¥~¼h­±ªO¤¤ªºÅÖºû§ô¡A¹³¦XªO¤@¼ËªuµÛ¤ìªOªø¶b§@©w¦V¡A¦]¦ÓªuµÛªø¶bªº±j«×­n
¤j©ó¯¶¶b¡C')

Is it even feasible to do even do this?

Don't put the value directly in your SQL statement - use a parameter.
That way it should all be done for you, so long as you've got the right
data in the string to start with.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top