Subject Re: Newlines etc. in string literals
Author peter_jacobi.rm
Hi Helen, Malte, All,

--- In firebird-support@yahoogroups.com, Helen Borrie wrote
(answering malte_starostik):
>> Back to the point. Is there any way to escape
>> an arbitrary character in a string literal, just
>> like \r\n\e\xff\040 in C-like languages?
>
> Nope. SQL is supposed to be host-language neutral,
[...]
> Have you tried concatenating it into your string
> literal using the UDF
> ascii_char??

There is a way to have character escaping in string literals,
it's only somewhat obscure (but easier to use than
ascii_char):

As character constants with escaped special characters can
be seen as a rather funny multi-byte character encoding,
you just have to define this character encoding in
fbintl2.dll.

I did a test with a character set LIKEJAVA, which understands
the \uXXXX UNICODE character escapes of Java, then things look
like:

insert into t1 (c1) values (_LIKEJAVA'A\u0008B\u0009C\u00C4D');

which inserts the seven characters:
A
<backspace>
B
<tab>
C
<CAPITAL LETTER A WITH DIARESIS>
D

Funny thing to play with.

So the situation is in fact better than in C: you can have
every type of character escaping you want to have, in addition
to LIKEJAVA, just define LIKEC and LIKEHTML.

Best Regards,
Peter Jacobi