0

I have a UTF-16 code, which is \D83D, and I want to get a symbol out of this code. I need some function like chr that returns nvarchar2 string. Like this:

select convert_utf16_to_nchar('\D83D') from dual;
Roman
  • 473
  • 5
  • 22
  • You do realize, though, that `\D83D` alone is not a valid UTF-16 code, right? It's the high surrogate of (many) surrogate pairs; by itself it is not a "symbol" of any kind. –  Sep 22 '21 at 18:25
  • @mathguy Yes, I do. The main problem was to transfer an `nvarchar2` record with this symbol from one DB to another. I've managed to get the so called "UTF-16 code" by using `asciistr` function but didn't get how I can reproduce this symbol by this code. – Roman Sep 23 '21 at 06:49

1 Answers1

2

I think you are looking for unistr

UNISTR takes as its argument a text literal or an expression that resolves to character data and returns it in the national character set. The national character set of the database can be either AL16UTF16 or UTF8. UNISTR provides support for Unicode string literals by letting you specify the Unicode encoding value of characters in the string. This is useful, for example, for inserting data into NCHAR columns.

Example

SELECT UNISTR('abc\00e5\00f1\00f6') FROM DUAL;

UNISTR
------
abcåñö
Roberto Hernandez
  • 8,231
  • 3
  • 14
  • 43