Re: String Function in Hebrew -
05-12-2008
, 08:51 AM
lshaki,
Interesting. This is the difference between the rendering of character
order visually and the way it is stored physically. Examine the results of
this query, added to your script.
select convert (varbinary(100),@a)
0xD905E905E805D005DC052000D005D505E805D80520003100 3100
You will notice that the rightmost characters are '11' in the string. Now,
instead of using '11' use '12' for your Hebrew string prefix and run the
script again. This time you will get:
0xD905E905E805D005DC052000D005D505E805D80520003100 3200
So, you can see that the string is not simply reversed. If it were that
simple, the last two characters would show as 32003100. So the rendering of
the Hebrew string is aware of the numerics reading left to right, while the
characters read right to left. Hebrew is technically a Bi-directional
Language (BIDI) not strictly right-to-left.
So, LEFT, RIGHT, SUBSTRING, etc all work on the order of data as stored in
the string, but not the order as it appears when rendered visually. (Yes, I
can see why that would be confusing, especially in a string with mixed
left-right and right-left characters.) You might find this article
interesting:
http://technet.microsoft.com/en-us/l.../bb330962.aspx
RLF
<lshaki (AT) gmail (DOT) com> wrote
I have a table containing Hebrew charachters
When I run String functions such as LEFT & SUBSTRING, that results
returned are in revers order.
I.E: The function LEFT will return the Right most charachters.
Try this
declare @a nvarchar(100)
set @a = '????? ???? 11'
select right(@a, 2)
The results I get for is '11' instead of '??'
Any idea? |