PC Review


Reply
Thread Tools Rate Thread

Character conversion from a .txt file

 
 
Quan
Guest
Posts: n/a
 
      26th Jan 2004
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.
 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      26th Jan 2004
Quan <(E-Mail Removed)> wrote:
> 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.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Quan
Guest
Posts: n/a
 
      26th Jan 2004
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?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      27th Jan 2004
Quan <(E-Mail Removed)> wrote:
> 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

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Quan
Guest
Posts: n/a
 
      28th Jan 2004
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.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      28th Jan 2004
Quan <(E-Mail Removed)> wrote:
> 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.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
character conversion DaveP Microsoft C# .NET 2 30th Jul 2007 02:30 AM
character to integer conversion lithium81 Microsoft Excel Programming 4 9th Mar 2006 10:50 AM
Character conversion in .NET Paul Selormey Microsoft Dot NET Framework 5 11th Jan 2005 05:52 PM
Character Conversion cgillett@shaw.ca Microsoft Access 1 12th Jan 2004 06:58 PM
Character conversion J. Ptak Microsoft ASP .NET 1 10th Jul 2003 12:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:52 PM.