473,385 Members | 1,311 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,385 software developers and data experts.

double-byte character

is it possible to detect any double-byte character in the text? thanks.

tony
Oct 2 '05 #1
3 7087


tony wong wrote:
is it possible to detect any double-byte character in the text? thanks.


Since JavaScript 1.3 (in Netscape 4.06) and JScript 4 (in IE 4) the
strings in JavaScript are sequences of Unicode characters, you can
access any character in a string with
string.charAt(index)
and the Unicode character code of any character in a string with
string.charCodeAt(index)
There is no byte type in JavaScript 1.x and there is no access to the
internal byte representation of an Unicode character or a complete string.
The internal string representation choosen is usually UTF-16 so in that
sense all characters are double byte characters. But as said, as a
scripter you deal with sequences of Unicode characters and the internal
encoding in bytes does not matter for scripting.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 2 '05 #2
tony wong <x3*@netvigator.com> wrote in message news:43******@127.0.0.1...
is it possible to detect any double-byte character in the text? thanks.


If you mean to detect the presence of any character whose hi-byte is non-zero:

if( /[\u0100-\uffff]/.test( text ) )
...

--
S.C.
Oct 2 '05 #3
Martin Honnen wrote:
The internal string representation choosen is usually UTF-16 so
in that sense all characters are double byte characters.


No, they are not. I thought a similar thing before (about UTF-8),
but this is not how UTF works. Additional code units (surrogate
pairs) are used if needed for a character, i.e. all Unicode
characters beyond code point 0xFFFF are represented in UTF-16/UCS2
by two 16-bit words or four bytes each.

<http://www.unicode.org/faq/basic_q.html#19>
<http://en.wikipedia.org/wiki/UTF-16/UCS-2>
PointedEars
Oct 16 '05 #4

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

Similar topics

12
by: Sydex | last post by:
When I compile code I get error C2664: 'Integration::qgaus' : cannot convert parameter 1 from 'double (double)' to 'double (__cdecl *)(double)' in this part : double Integration::quad2d(double...
20
by: Anonymous | last post by:
Is there a non-brute force method of doing this? transform() looked likely but had no predefined function object. std::vector<double> src; std::vector<int> dest; ...
4
by: Michael Mair | last post by:
Hi there, actually, I have posted the same question in g.g.help. As there were no answers, I am still not sure whether this is a bug or only something open to the compiler that is seemingly...
31
by: Bjørn Augestad | last post by:
Below is a program which converts a double to an integer in two different ways, giving me two different values for the int. The basic expression is 1.0 / (1.0 * 365.0) which should be 365, but one...
10
by: Robert Palma | last post by:
I'm having trouble figuring out how to pass a pointer to a double array (1 dimensional) to a C function. Declaring array as: double xx; Declaring func. int process( double *input ) Calling...
10
by: Bryan Parkoff | last post by:
The guideline says to use %f in printf() function using the keyword float and double. For example float a = 1.2345; double b = 5.166666667; printf("%.2f\n %f\n", a, b);
3
by: BlueTrin | last post by:
I am using a DLL written in C, it uses some pointers on functions, I have defined a wrapper around it in C# which uses some delegates: #region Delegates and Marshalling to call solvopt public...
67
by: lcw1964 | last post by:
This may be in the category of bush-league rudimentary, but I am quite perplexed on this and diligent Googling has not provided me with a clear straight answer--perhaps I don't know how to ask the...
52
by: lcw1964 | last post by:
Greetings, all, I am trying to port a little bit of math code to gcc, that in the original version used the long double version of several functions (in particular, atanl, fabsl, and expl). I...
2
by: Genro | last post by:
#include<stdio.h> #include<TX/graphics.h> #include<time.h> // I need help! struct Krug{ double _x; double _y; double _skox; double _skoy; double...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.