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

HTML Escape Sequence versus \

Hello,

I'm having problems with the apostrophe character when building a
Javascript array.

I've come up with two different ways to fix the problem. I wondered
if any one had any input as to which approach would be "best
practices" and why.

Approach 1:

var aMyArray = new Array();
aMyArray[aMyArray.length] = new Array('Person's name.',
'',
'False',
'',
'True');

Approach 2:

var aMyArray = new Array();
aMyArray[aMyArray.length] = new Array('Person\'s name.',
'',
'False',
'',
'True');

Thanks,
Eric
Jan 18 '08 #1
2 3188
pr
Eric wrote:
I'm having problems with the apostrophe character when building a
Javascript array.

I've come up with two different ways to fix the problem. I wondered
if any one had any input as to which approach would be "best
practices" and why.

Approach 1:

var aMyArray = new Array();
aMyArray[aMyArray.length] = new Array('Person's name.',
Unless the programmer retains a table of ASCII codes in their head, this
approach is going to be slightly more troublesome to maintain.

[...]
Approach 2:

var aMyArray = new Array();
aMyArray[aMyArray.length] = new Array('Person\'s name.',
This is more normal.

Simplest of all is:

aMyArray[aMyArray.length] = new Array("Person's name.", ...
Jan 18 '08 #2
pr
pr wrote:
Eric wrote:
>aMyArray[aMyArray.length] = new Array('Person's name.',

Unless the programmer retains a table of ASCII codes in their head, this
approach is going to be slightly more troublesome to maintain.
and I should have asked if you really meant ''' or '\u0027'.

See
<URL:http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Literals#Using_Special_C haracters_in_Strings>
<URL:http://www.w3.org/TR/html401/charset.html#h-5.3.1>
Jan 19 '08 #3

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

Similar topics

3
by: harrelson | last post by:
I have a list of about 2500 html escape sequences (decimal) that I need to convert to utf-8. Stuff like: 비 행 기 로 보 낼 거
8
by: Joe | last post by:
I'm using Python 2.4 on Windows XP SP2. I'm trying to receive a command line argument that is a newline (\n) Here is the command line to use sample.py "\n" Here is a sample.py script
1
by: Evgeny Zoldin | last post by:
Hi, ALL. Namely SUBJ... E.g, I have HTML source of some page. How to convert in .NET '>' , '&nbsp;' etc. into its simple String analoques '>' and ' ' respectevely? Thanks Evgeny
1
by: Didier Bretin | last post by:
Hello, Is there some escape sequence for using unicode characters in command line psql ? For example in HTML there is e; for the c-cedilla. Is there the same thing with postgresql ? ...
7
by: N U | last post by:
How to program your own escape sequence using basic functions available in C?
2
by: junky_fellow | last post by:
N869 " Each of these escape sequences shall produce a unique implementation-defined value which can be stored in a single char object. The external representations in a text file need not be...
4
by: Guadala Harry | last post by:
I need to place the following into a string... How can I properly escape the % " / < and > characters? <table width="100%" border="0" cellspacing="0" cellpadding="4px" class="hfAll"></Table> ...
2
by: Christopher Ireland | last post by:
Hi -- Any ideas on this one please ... The following code works as expected: private void Form1_Load(object sender, System.EventArgs e) { string text = "The quick brown"+ " FOX " +"jumps over...
5
by: vlsidesign | last post by:
The printf function returns "warning: unknown escape sequence: \040" for a backslash-space combination. If the ascii decimal number for space is 32 and the backslash is 92, why this particular...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
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
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,...

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.