Double byte strings in javascript

I have a web page with a <select> listbox that contains both English
strings and Kanji-character strings in the options. The charset on the
page is set to UTF-8 and on load of the page, both language strings
are displayed correctly.

I have a javascript function where the user can select a list item and
click on a button to move it up in the sequence or down, basically to
let them set an order among the list items. The logic used is a simple
swap of two values, with the selected item value stored in a temp.
variable, the selected item replaced with the next item in the list
and the next item replaced with the temp. variable. Below is the code
for moving up the item,

I notice that as long as one Kanji-character list item is swapped with
another Kanji-character list item, the display is still fine. However,
when an English string and a Kanji-character string are swapped, the
Kanji-character display is lost and starts showing boxes in place of
the characters.

What am I doing wrong? Any help will be appreciated as this issue is
holding up entire application deployment.

Advertisements

On 12 Sep 2004 11:02:21 -0700, (Tharika) wrote:
>I notice that as long as one Kanji-character list item is swapped with
>another Kanji-character list item, the display is still fine. However,
>when an English string and a Kanji-character string are swapped, the
>Kanji-character display is lost and starts showing boxes in place of
>the characters.

At a guess you're running into a bug with the SELECT control, it's
double-byte support is probably dodgy - you're not doing anything
wrong as I can see it, so you're going to have to look at workarounds,
rather than swapping innerText's maybe swap .text or create new
elements each time, or... who knows you'll probably have to try it
I'm afraid. Your code should IMO just work, but I'm not surprised the
native select control doesn't do this too well.

Advertisements

Your suggestion turned out to be very beneficial. I replaced the
innerText in the code with text and it worked I am still trying to
figure out the difference in the properties.

Thanks a ton!..... Tharika

> At a guess you're running into a bug with the SELECT control, it's
> double-byte support is probably dodgy - you're not doing anything
> wrong as I can see it, so you're going to have to look at workarounds,
> rather than swapping innerText's maybe swap .text or create new
> elements each time, or... who knows you'll probably have to try it
> I'm afraid. Your code should IMO just work, but I'm not surprised the
> native select control doesn't do this too well.
>
> Jim.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!