为什么我能够使用不是字符集(Windows-1252)的一部分的字符? [英] Why am I able to use a character that's not part of a charset (windows-1252)?
问题描述
我正在寻找一点帮助,了解charsets的工作原理。这个问题是从使用windows- 1252而不是UTF-8
我有一个测试ColdFusion网站使用...
< CFHEADER NAME =Content-Typevalue =text / html; charset = windows-1252>
< meta http-equiv =Content-Typecontent =text / html; charset = windows-1252/>
和测试Oracle DB使用...
NLS_CHARACTERSET:WE8MSWIN1252
NLS_NCHAR_CHARACTERSET:AL16UTF16
根据windows-1252字符集没有平方根符号(alt + 251):√但我可以键入它到一个网页表单上的字段,保存到DB,查询它,并再次显示在屏幕上精细。当它在DB中时,它存储为:&#8730;
。我如何输入,存储,查询和显示它,如果它甚至不是字符集的一部分?根据字符集,decimal 251是这样: Hex:FB | û| 00FB |拉丁小写字母U与CIRCUMFLEX
数据库的字符集。
由于页面是windows-1252编码的,如果在表单字段中输入Alt + 251,然后发布数据,浏览器会显示:
嘿这个字符不是windows-1252的区别,我只需要发回数据
这是在windows-1252 ,所以我将尽最大努力,并发回
html字符代码char&#8730; - 哦,我希望我可以发回
1个字符,因为我不能发回7.
如果你注意到,这是Windows-1252字符集中的7个不同的字符。 p>
如果页面使用多字节字符集进行编码,浏览器将发回一个被认为是1个字符的内容。
那么你如何查询呢?
从选项卡中选择%&#8730;%'
你有的是平方根符号的html字符: https://www.google.com/#q=html+character+codes
更新:
这是一篇非常好的文章,解释发生了什么: http://htmlpurifier.org/docs/enduser-utf8.html
...一旦你开始在编码之外添加字符...
[浏览器可能]用字符实体引用替换字符....
此外,当在Windows机器上输入Alt + 251时,它会插入平方根符号,在Unicode中为U-221A。 p>
按Alt + 251就像一个键盘宏插入Unicode是U-221A。
I'm looking for a little help in understanding how charsets work. This question is a continuation from Anything wrong with using windows-1252 instead of UTF-8
I have a test ColdFusion site using...
<CFHEADER NAME="Content-Type" value="text/html; charset=windows-1252">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
and a test Oracle DB using...
NLS_CHARACTERSET: WE8MSWIN1252
NLS_NCHAR_CHARACTERSET: AL16UTF16
According to the windows-1252 charset there is no square root symbol (alt+251): √ But I can type that into a field on a webpage form, save it to the DB, query it and show it on the screen again just fine. When it's in the DB it's stored as: √
. How can I enter that, store it, query and show it if it's not even part of the charset? According to the charset, decimal 251 is this: Hex:FB | û | 00FB | LATIN SMALL LETTER U WITH CIRCUMFLEX
You're not really using characters outside of the page and database's charset.
Because the page is windows-1252 encoded, if you enter Alt+251 into a form field and then post the data, the browser says:
"Hey this char is not apart of windows-1252 and I need to only send back data
which is in windows-1252, so I will do the best I can and send back the
html character code of char √ -- oh well, I wish I could send back
1 character, since I cannot I will send back 7."
And if you notice, this is 7 different characters which are in the windows-1252 charset.
Had the page been encoded with a multibyte charset, the browser would send back something which is considered 1 character.
So how can you query it?
select * from tab where field like '%√%'
What you have is the html character of the square root symbol: https://www.google.com/#q=html+character+codes
Update:
Here is a very good article explaining what is happening: http://htmlpurifier.org/docs/enduser-utf8.html
"...once you start adding characters outside of your encoding...
[the browser might] replace the character with a character entity reference...."
Also when you enter Alt+251 on a windows machine, it inserts the square root symbol which in Unicode it is U-221A.
Pressing Alt+251 is just a like a keyboard macro to insert Unicode it is U-221A.
这篇关于为什么我能够使用不是字符集(Windows-1252)的一部分的字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!