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

javscript: specific chars decode problem

Code sample:

<script>
alert("°")
document.write("°")
</script>

Question: How can I force alert() to produce the same
result as document.write() ?

unescape() does not work.

Thank you, Dmitry
Jul 23 '05 #1
2 1613
Dmitry <no****@nospam.com> wrote in message
news:cv***********@news.peterlink.ru...
Code sample:

<script>
alert("°")
document.write("°")
</script>

Question: How can I force alert() to produce the same
result as document.write() ?

unescape() does not work.

Thank you, Dmitry

You need to extract the numeric value from the html code, then convert it to
an integer whose value you convert to a single-character string.

alert( String.fromCharCode( parseInt( "°".replace( /\D/g, "" ) ) )

If you intend do this repeatedly, it's best to write a function:

function htmlToChar(charCode)
{
return String.fromCharCode( parseInt( charCode.replace( /\D/g, "" ) ) );
}

alert( htmlToChar("°") );

....unless someone knows another way that eludes me...
--
S.C.

http://makeashorterlink.com/?H3E82245A


Jul 23 '05 #2
Thank you, I've thought about something simular,
but the best thing is to have a fn for all cases,
ie the fn, which accept a string, possibly containing
html char codes together with plain chars and returns
decoded string.

I'am not so good in regular expressions programming,
so any help in writing this fn will be greately
appreciated.

Thanks, Dmitry
Jul 23 '05 #3

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

Similar topics

0
by: Chris Lambacher | last post by:
Hi, I have to do some data manipulation that needs to be fast. I had a generator approach (that was faster than a list approch) which was taking approximately 5 seconds to run both encode and...
3
by: Supratim | last post by:
Hi, For past few weeks I am working on a function that would take encoded Unicode characters from query string of http requests and then decode them back to Unicode numbers. I have full success...
1
by: richasaraf | last post by:
Hello everyone, I'm facing problem in converting CASE statements into DECODE. As i have PL/SQL 8i, so it does not handle CASE statements. Please send me the solutions . Then basic problem is the...
18
by: cjl | last post by:
Hey all: I know that it is silly in the age of Google to 'lose' something on the internet, but I recently checked out a project that had implemented a database with a subset of SQL in pure...
0
by: richasaraf | last post by:
Hello everyone, Please HELP !!!!! I'm facing problem in converting CASE statements into DECODE. As i have PL/SQL 8i, so it does not handle CASE statements. Please send me the solutions . Then...
20
by: Drebin | last post by:
It's a long story really, but the bottom line is we need to encrypt or obfuscate a clear-text 9-digit SSN/taxpayer ID into something less than 21 characters. It doesn't need to be super-secure,...
1
by: dande | last post by:
my problem is I have used invoice table, patient table.In Invoice table date,cash,credit, cheque,advance,total is coming.but in patient table having registration type code having gen registraion...
6
by: 7stud | last post by:
s = 'A\xcc\x88' #capital A with umlaut print s #displays capital A with umlaut s = raw_input('Enter: ') #A\xcc\x88 print s #displays A\xcc\x88 print...
6
by: Christoph Zwerschke | last post by:
In Python programs, you will quite frequently find code like the following for removing a certain prefix from a string: if url.startswith('http://'): url = url Similarly for stripping...
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: 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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.