473,508 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1618
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
2817
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
5220
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
3708
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
7342
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
3485
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
4130
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
2760
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
4198
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
4118
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
7228
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
7128
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
7332
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
7393
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
7058
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
7502
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...
1
5057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
426
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.