PDA

View Full Version : html formatted text with special characters for field emtyText?



philipp_sidarion
9 Jun 2010, 10:53 PM
Hi!

I have a question regarding html formatted text with special characters (like eg. ). When I create a new form-object like e.g. new Ext.form.TextField, the field "fieldLabel" accepts html formatted text, but the field "emptyText" does not. So the following code does display as ä and so on in the field istelf, the field label is correct...



var vTestTextField = new Ext.form.TextField({
fieldLabel: 'äöü',
emptyText: 'äöü',
hiddenName: 'test',
...
});



Does anybody now if/how I can use html code in the emptyText field or how I have to deal with special characters with this field?
Thanks a lot for your support
Philipp

CrazyEnigma
9 Jun 2010, 11:21 PM
I know you might have tried this, but have you tried setting the character directly inside the field rather than its html equivalent?

philipp_sidarion
9 Jun 2010, 11:31 PM
I tried to use the special characters directly and not the html equivalent, this worked, but I fear that then I could run into display problems with different client systems, moreover, the client of a friend of mine who is also editing the source code always transforms the text to "non utf-8", changing the special characters to some other ascii equivalent stuff...

Animal
10 Jun 2010, 12:00 AM
Use Javascript unicode literal notation.

https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Core_Language_Features#String_Literals

or

http://www.json.org/draft-crockford-jsonorg-json-04.txt Section 2.5. Strings

philipp_sidarion
10 Jun 2010, 1:14 AM
Hi!

Cool, using \XXX (Latin1 Encoding) solved my problem! Thanks for the solution!
Regards Philipp

CrazyEnigma
10 Jun 2010, 5:29 AM
The bottom line is that if the system renders as HTML, it will want &<special html char name>; but if javascript is using it, it will not interpret the HTML equivalent, rather the literal character or an escaped unicode equivalent.

Just like there is a huge difference between using \n and <br />.