Re: Escaping international (unicode) characters in string



Erland Sommarskog <esquel@xxxxxxxxxxxxx> wrote in
news:Xns993F9F38ABD05Yazorman@xxxxxxxxx:

Greg R. Broderick (usenet200705@xxxxxxxxxxxxxxxxxxxxx) writes:
I am needing some way, in the SQL Server dialect of SQL, to escape
unicode code points that are embedded within an nvarchar string in a
SQL script, e.g. in Java I can do:

String str = "This is a\u1245 test.";

SELECT @str = 'This is a' + nchar(1245) + ' test'

Note here that 1245 is decimal. If you want to use hex code (which you
normally do with Unicode), you would do:

SELECT @str = 'This is a' + nchar(0x1245) + ' test'

When there are more than one or two non-US-ASCII characters in the string,
this quickly becomes impractically unwieldy, thus my comment in my original
posting:

--- quote ---

I am already aware of the UNISTR() function, and the NCHAR() function, but
those aren't going to work well if there are more than a few international
characters embedded within a string.

--- quote ---

Thanks anyway, though. :-)

--
---------------------------------------------------------------------
Greg R. Broderick usenet200705@xxxxxxxxxxxxxxxxxxxxx

A. Top posters.
Q. What is the most annoying thing on Usenet?
---------------------------------------------------------------------
.



Relevant Pages

  • Re: how do I expand a unicode string to its visual UTF8 representation?
    ... Java strings are sequences of 16-bit units (exactly the kind ... E.g., the Unicode code point for 'A' is 65, ... The first is to handle an internationalisation ... stored in a varchar column where the string contains HTML to handle ...
    (comp.lang.java.programmer)
  • Re: Delphi Quiz: SetLength( WideString, 10 );
    ... >> Unicode code points in ascending order, ... I imagine it will return a UTF-16-encoded string. ... exist in UCS-2 will appear as normal UCS-2 characters. ... only present in UCS-4 will be encoded in multiple words, ...
    (alt.comp.lang.borland-delphi)
  • Re: String from code points?
    ... In message "Re: String from code points?" ... |Given a(n array of) numeric valuerepresenting Unicode code ...
    (comp.lang.ruby)
  • Re: codecs limitation
    ... > encodings like 'html'? ... I suppose it depends on what the codecs system is *for*. ... interface that goes between between the abstract world of Unicode code ... then the idea of returning anything but an 8-bit string from ...
    (comp.lang.python)
  • String from code points?
    ... Given a(n array of) numeric valuerepresenting Unicode code ... how do I get a string of the indicated character? ...
    (comp.lang.ruby)