UDR InMsg/OutMsg and char/varchar types

12 views
Skip to first unread message

Virgo Pärna

unread,
Jun 2, 2021, 5:16:14 AMJun 2
to firebird-support
How are CHAR and VARCHAR represented in the IExternalFunction.execute
InMsg and OutMsg parameters represented? Say, for CHAR(10) - is it 10
bytes, when it is defined as CHAR(10) CHARACTER SET WIN1252, but 40
bytes, when it is defined as CHAR(10) CHARACTER SET UTF8?
But how is VARCHAR represented? Exactly same as CHAR?

--
Virgo Pärna
Gaiasoft OÜ
vi...@gaiasoft.ee

Dmitry Yemanov

unread,
Jun 2, 2021, 10:11:47 AMJun 2
to firebird...@googlegroups.com
02.06.2021 12:16, Virgo Pärna wrote:

> How are CHAR and VARCHAR represented in the IExternalFunction.execute
> InMsg and OutMsg parameters represented? Say, for CHAR(10) - is it 10
> bytes, when it is defined as CHAR(10) CHARACTER SET WIN1252, but 40
> bytes, when it is defined as CHAR(10) CHARACTER SET UTF8?

Correct.

> But how is VARCHAR represented? Exactly same as CHAR?

First two bytes represent the 16-bit length. The remaining "length"
bytes are the string itself.


Dmitry

Virgo Pärna

unread,
Jun 3, 2021, 12:47:05 AMJun 3
to firebird...@googlegroups.com
On 2.06.2021 17:11, Dmitry Yemanov wrote:
> 02.06.2021 12:16, Virgo Pärna wrote:
>
>> bytes, when it is defined as CHAR(10) CHARACTER SET WIN1252, but 40
>> bytes, when it is defined as CHAR(10) CHARACTER SET UTF8?
>
> Correct.

Ok. So it is good idea to also specify character set on UDR definition
SQL to avoid having mismatch between database character set and UDR
character set.
And unused bytes at the end should be spaces (0x20)? Also in UTF8?

>
>> But how is VARCHAR represented? Exactly same as CHAR?
>
> First two bytes represent the 16-bit length. The remaining "length"
> bytes are the string itself.
>

So length it length in bytes, which for UTF8 encoded string is actual
length of UTF8 encoded string in bytes (1 for "F", but 2 for "Ä")?
Reply all
Reply to author
Forward
0 new messages