473,473 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Foreign langauge arrray element separator

When I create an array I use commas as the separator between elements of
the array e.g [1.1, 2.2, 3.3] but what happens with languages that use
commas as a number's "decimal point"? e.g. [1,1, 2,2 , 3,3] is now a 6
element array.

Andrew Poulos
May 24 '06 #1
4 1168
Andrew Poulos wrote:
When I create an array I use commas as the separator between elements of
the array e.g [1.1, 2.2, 3.3] but what happens with languages that use
commas as a number's "decimal point"? e.g. [1,1, 2,2 , 3,3] is now a 6
element array.


That is irrelevant. Javascript numeric literals only use the '.'
character as a decimal point.

Richard.

May 24 '06 #2
Richard Cornford wrote:
Andrew Poulos wrote:
When I create an array I use commas as the separator between elements of
the array e.g [1.1, 2.2, 3.3] but what happens with languages that use
commas as a number's "decimal point"? e.g. [1,1, 2,2 , 3,3] is now a 6
element array.


That is irrelevant. Javascript numeric literals only use the '.'
character as a decimal point.


But what happens when someone, from a place where it's normal to use
commas, enters a number with a comma into a field from which I use
javascript to get the value? Do I have to do a conversion like this on it:

num = num ^ "";
num = parseFloat( num.replace(/,/g, ".") );

Andrew Poulos
May 24 '06 #3
Andrew Poulos:
commas as a number's "decimal point"? e.g. [1,1, 2,2 , 3,3] is now a 6
element array.
But what happens when someone, from a place where it's normal to use
commas, enters a number with a comma into a field from which I use
input value is a string
your array presents something like this
['1,1', '2,2' , '3,3']
and array doesn't "destroy"
javascript to get the value? Do I have to do a conversion like this on it:
if you want to use them in mathematical operation...


num = num ^ "";
num = parseFloat( num.replace(/,/g, ".") );


so, imagine someone enters "price number format"?
1,234,567.00
what are you going to do?

--
BlaTek
May 24 '06 #4
VK

Andrew Poulos wrote:
But what happens when someone, from a place where it's normal to use
commas, enters a number with a comma into a field from which I use
javascript to get the value? Do I have to do a conversion like this on it:

num = num ^ "";
num = parseFloat( num.replace(/,/g, ".") );


Something like that. But first you have to spell clearly on the page in
what format do you want to have the number typed. There is nothing
"illegal" to spell your formatting rules. Comma is used as "readability
separator" in the US and as decimal point in some Western countries.
Period used as decimal point in the US and as "readability separator"
in Japan, where period is used as decimal point. Unless you know
exactly that format is used by the customer, any attempt to guess the
entered number is pretty futil. Even if you manage to know the
SystemLanguage, it doesn't prove anything in application to this
particular customer sitting and typing on the computer. So just play
from your side of the table: "please inter the numbers in this format:
XXXXX and I don't give a damn what you've been thaught in your damn
local school" :-) Obviously the required format should be as used by
the majority of the expected customers. If you cannot determine such
majority, then drop a coin.
:-)

May 24 '06 #5

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

Similar topics

0
by: Christopher Boomer | last post by:
I am relatively new to the world of XML and python, and I think I am still missing some of the basic concepts. It cannot be as hard as I think, or programmers would be flocking to it the way they...
21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
43
by: David Trimboli | last post by:
In a text, I might want to include a foreign language term. In print, this is typically shown with italics. For instance (asterisks represent italics): 'I thought it was only a kind of *cram,*...
47
by: Andy Dingley | last post by:
Assume an English language page, linking to a foreign history resource that's only available in a foreign language. Any suggestions on appropriate "best practice" markup, particularly regarding the...
1
by: dalei | last post by:
I like to make foreign letters to appear in the textarea. For instance, when typing the letter 'a' on the keyboard, the Japanese letter &#+12449; would appear in the textarea. Could somebody...
2
by: Jeremy Chapman | last post by:
Populating a typed dataset from xml document: I created an xml schema (attached below), generated a typed dataset from it, and then programatically I tried to populate the typed dataset by...
2
by: ahmed ahmed | last post by:
VB.NET hi i'm asking about How To Change System Keyboard langauge from the VB.NET or Keyboard langauge from langauge to another without the API function. and thanks about helping me. ***...
0
by: raghuveer | last post by:
i want to implement multiple stacks using arrays..I am able to create ,insert and print them but not poping an element form any of the stack..This is what i have #include<stdio.h>...
8
by: Scott Sauyet | last post by:
I found myself needing to find my way recursively through a document in XSLT, finding the dependencies one element had on others, and including only those in an initial set, their dependencies, the...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.