473,803 Members | 4,195 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with special chars

Hi everyone,

I've got a problem with a piece of javascript code which parses a
string. The problem occurs when the string contains some special
characters like é, è, ü...

There are 2 symptoms
The string shows up incomplete, i.e. Günther =G? or sometime I have
javascript error :
"End of file reached in invalid state for current encoding"

The string is used to populate a select box, so converting the special
chars into HTML entities didn't work...

Could anyone help me out ?
Thx!
Mathew

Mar 13 '07 #1
2 4168
Lupus wrote:
I've got a problem with a piece of javascript code which parses a
string. The problem occurs when the string contains some special
characters like é, è, ü...

There are 2 symptoms
The string shows up incomplete, i.e. Günther =G? or sometime I have
javascript error :
"End of file reached in invalid state for current encoding"
Well make sure you choose an appropriate encoding for your files and use
a text editor which saves in that encoding, then make sure the HTTP
server serves the files indicating the encoding.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 13 '07 #2
Lupus wrote:
I've got a problem with a piece of javascript code which
parses a string. The problem occurs when the string contains
some special characters like é, è, ü...

There are 2 symptoms
The string shows up incomplete, i.e. Günther =G? or sometime
I have javascript error :
"End of file reached in invalid state for current encoding"

The string is used to populate a select box, so converting the
special chars into HTML entities didn't work...
One possible solution which allows you to use all characters that a
browser can display, without needing to save them as such:

alert('\u00e8\u 00e9\u00fc')

The tables at http://unicode.coeurlumiere.com/ give you every code
point that the javascript engine supports (65535 combinations in hex).
Just replace the last zero of the left code by the character in the
upper row, like eg \u0079 for 'y'.

With this approach you can always save your programming code in ASCII,
which is a full guarantee to never have this kind of problems. Quick
and dirty! :)

--
Bart

Mar 13 '07 #3

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

Similar topics

6
2795
by: Jonas Meurer | last post by:
hello, my script selects a comment saved as VARCHAR in MySQL and displays it inside an html page. the problem is, that the comment contains several special characters, as mysterious utf-8 hyphens, german umlauts, etc. i could write a function to parse the comment and substitute special chars with the relevant html code, but maybe this already exists in some
6
3994
by: Horst Gutmann | last post by:
Hi :-) I currently have quite a big problem with minidom and special chars (for example &uuml;) in HTML. Let's say I have following input file: -------------------------------------------------- <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html>
2
1648
by: Thorsten Viel | last post by:
Hi List, im trying to use special chars with the std::string (like S) but when i cout<< the string the special chars have disappeared. What's wrong here? Thanks in advance
4
2653
by: dutch disCo | last post by:
Hi, I'm trying to use GET method to pass variables through my script files. Unfortunately, when a special char (&, ?, +) is being posted the variable gets trimmed in a very strange way. I'm aware, that's connected with the way the GET method passes variable values, but I don't know how to make GET to take the variable value "as it is" without interpreting special chars as special chars. So, how should I send GET variables in order not...
3
10172
by: VMI | last post by:
When I execute a ReadLine from an ascii file with special chars (ie. the 'Ñ' in "NUÑEZ PEREZ"), it automatically deletes this character. So "NUÑEZ PEREZ" becomes "NUEZ PEREZ". How can this be avoided? The reason being that I compare this string to a string in an Access DB (btw, Access also screws up with the character by replacing "Ñ" with "-"). So when I compare these two strings, they won't match because both systems storing the data...
0
1083
by: Frank M | last post by:
I am writing an application with a dataload class. The development is done in Windows XP, and on the development Pc I can do a dataload and export without any problems if I use System.Text.UTF8Encoding on the datastream for writing. The datafile is still in windows standard codepage, also for the special chars for Scandinavia (e.g. æ,ø,å). However, when I transfer my application to a Pc running Windows 2000, the special chars...
5
8634
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file". Same file path containing special characters works fine in one machine, but doesn't work in other. I am using following API function to get short file path. Declare Auto Function GetShortPathName Lib "kernel32" (ByVal lpszLongPath As
8
2919
by: abhi147 | last post by:
Hi , I have been trying to convert a 32 bit string like "b2a4fdf15af7c4f215e1909be4707bdb" to convert to a string of special chars like "²¤ýñZ÷Äòá?›äp{Û" I have tried a lot of things .. but nothing works . I have no idea how to go further . Can anyone help me ? Thanks in advance.
5
4164
by: Alex | last post by:
Hi all - Is there a standard way to handle special chars in strings in dotnet? I'm using csharp and having two seperate problems... 1. Passing in args... I need to pass in an arg that points to a sqlserver2005 instance... it comes in looking like this in the debugger:
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10542
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10289
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10068
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9119
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6840
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5496
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.