Shift-JIS to UTF8 string conversion and c#

  • Thread starter Thread starter Mikael Karon
  • Start date Start date
M

Mikael Karon

Hi,

I'm desperatly trying to convert a string wich I have in Shift-JIS
(@", ,È,½,̉pŒê,̃Œƒxƒ‹") to UTF8 but I just
can't get it to work. One would thing this would be trivial and well
documented somewhere (perhaps it is and I'm not getting/finding it) but
however much I try I just can't get it to work.

I'm trying to do this on a webpage (Do I need to play with
Response.ContentEncoding?), and all I want to do is to convert that
string into UTF8 and output it (well, in the future I'd probably want
to pop it into a database to).

Any ideas ?

regards / Mike
 
Mikael Karon said:
I'm desperatly trying to convert a string wich I have in Shift-JIS
(@", ,È,½,Ì?p?ê,Ì???x??") to UTF8 but I just
can't get it to work. One would thing this would be trivial and well
documented somewhere (perhaps it is and I'm not getting/finding it) but
however much I try I just can't get it to work.

I'm trying to do this on a webpage (Do I need to play with
Response.ContentEncoding?), and all I want to do is to convert that
string into UTF8 and output it (well, in the future I'd probably want
to pop it into a database to).

Any ideas ?

It would help if you could be a bit more precise about what you've got.
Where are you getting the information from? Strings are always in
Unicode in .NET - you need to make sure you're converting it in the
right way to start with.
 
originally the string is comming from a database, but in my experiments
I've just hard-coded it (string jisString=@",
,È,½,̉pŒê,̃Œƒxƒ‹";).
 
Mikael Karon said:
originally the string is comming from a database, but in my experiments
I've just hard-coded it (string jisString=@",
,È,½,Ì?p?ê,Ì???x??";).

Well, if you're hard coding it, it *will* be in Unicode, however you've
specified it. It may not represent the characters you want it to
though.

If you want to be absolutely sure, find out the Unicode values you want
and specify the value as

string foo = "\uxxxx\uyyyy" etc.
 
Back
Top