473,320 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Double byte strings in javascript

Hi,

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,

function GoUp()
{
var i, j, s, seltext, selval, selcol

if (frmModCon.lstConSeq.length > 0)
{
j = frmModCon.lstConSeq.selectedIndex;
if (j != -1)
{
seltext = frmModCon.lstConSeq(j).innerText;
selval = frmModCon.lstConSeq(j).value;
selcol = frmModCon.lstConSeq(j).style.color;
s = parseInt(frmModCon.lstConSeq.length) - 1;

if (j!=0)
{
i = parseInt(j) - 1;

frmModCon.lstConSeq.item(j).selected = false;
frmModCon.lstConSeq(j).innerText =
frmModCon.lstConSeq(i).innerText;
frmModCon.lstConSeq(j).value = frmModCon.lstConSeq(i).value;
frmModCon.lstConSeq(j).style.color =
frmModCon.lstConSeq(i).style.color;

frmModCon.lstConSeq.item(i).selected = true;
frmModCon.lstConSeq(i).innerText = seltext;
frmModCon.lstConSeq(i).value = selval;
frmModCon.lstConSeq(i).style.color = selcol;
}
}
}
}

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.

Thanks........... Tharika
Jul 23 '05 #1
2 2486
On 12 Sep 2004 11:02:21 -0700, th*****@gmail.com (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.

Jim.
Jul 23 '05 #2
Hi Jim,

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.

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Dorthe Luebbert | last post by:
Hi, we have to convert a quite large ISO-application (Mysql4, PHP5) to UTF8. We found out so far that there is no collation for MySQL which is able to sort all character sets correctly. So this...
3
by: tony wong | last post by:
is it possible to detect any double-byte character in the text? thanks. tony
14
by: Lyle Fairfield | last post by:
d1 and d2 are numbers we can store as doubles (8 bytes). d1 > 0 d2 > 0 d1 < d2 Now s1 and s2 are strings of length 8 bytes. (We can ignore unicode here). Into s1 and s2 we copy the 8 bytes...
22
by: bq | last post by:
Hello, Two questions related to floating point support: What C compilers for the wintel (MS Windows + x86) platform are C99 compliant as far as <math.h> and <tgmath.h> are concerned? What...
3
by: RoSsIaCrIiLoIA | last post by:
I have rewrote the malloc() function of K&R2 chapter 8.7 typedef long Align; ^^^^ Here, should I write 'long', 'double' or 'long double'? I know that in my pc+compiler sizeof(long)=4,...
17
by: Terry | last post by:
I have some old VB5 functions that specify types of Long and Double that make calls to an unmanaged 3rd party DLL probably just as old. The source for the DLL is not available. I'm getting some...
5
by: anders.weitman | last post by:
Hi! I want to get the representation in memory of a variable of type double and put it in an array of four unsigned short int (I'm on a 32- bits Windows architecture so a double is 64-bits and...
7
by: Angus | last post by:
I am writing a class which represents a byte array - ie an array of unsigned char. So far I have worked out how to add strings, integers, WORD's, etc. But how would I add a double? Would I...
29
by: Virtual_X | last post by:
As in IEEE754 double consist of sign bit 11 bits for exponent 52 bits for fraction i write this code to print double parts as it explained in ieee754 i want to know if the code contain any...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.