UTF-8 to Shift JIS

E

Ed Brandmark

I need to convert an UTF-8 string to Shift-JIS in a web page
(preferably using JavaScript).
Any ideas?
thanks
Ed Brandmark
 
D

Douglas Crockford

I need to convert an UTF-8 string to Shift-JIS in a web page
(preferably using JavaScript).

I'm curious why? One of the services that the browser provides is automatic
conversion of character encodings, so that scripts can deal exclusively in
Unicode, which is a very, very good thing. Normally, encodings are specified in
http headers and it all works out. Why doesn't that work for you?

http://www.crockford.com
 
E

Ed Brandmark

This is part of an ad call where a Japanese web page is encoding what
the user typed in as a search term.
This needs to be encoded in UTF-8 for our server to be able to
understand the search term - and thus pick a relevant ad.

Then in some of the ads, they want to put the search term right back in
the ad - so for an amazon ad - it could say click here to find books
about ...

well the term that gets put back there is the term they converted to
UTF-8. when their web page then displays this - it is not converted
correctly - thus we must convert it back to Shift-JIS before displaying
it.

in some cases i use encodeURIComponent to do this - and it seems there
is a decodeURICompoenent that may work.
in other cases (older browsers that don't understand encodeURIComponent)
they use a home grown routine - which I guess we will have to reverse?

thanks
 

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

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top