Two characters with the same ASCII Code?
I'm trying to clean a recently imported sql server 2008 database that have to many invalid charcters for my application. and I found different characters with the same ASCII code, ¿that is posible?.
If I execute this query:
select ASCII('║'), ASCII('¦')
I get:
166 166
I need to do a similar work, but with .net code.
If I ask for these char in .net:
? ((int)'║').ToString() + ", " + ((int)'¦').ToString()
I get:
"9553, 166"
Anybody can Explain w开发者_开发知识库hat happens
Instead of ASCII
, use the UNICODE
function.
Both ║
and |
are not an ASCII characters, so calling ASCII
with them would convert incorrectly and result in the wrong value.
Additionally, you need to use unicode strings when calling the UNICODE
function, using the N
prefix:
SELECT UNICODE(N'║'), UNICODE(N'|')
-- Results in: 9553, 166
精彩评论