PQunescapeBytea
От | Iker Arizmendi |
---|---|
Тема | PQunescapeBytea |
Дата | |
Msg-id | 4029339D.5040302@research.att.com обсуждение исходный текст |
Ответы |
Re: PQunescapeBytea
|
Список | pgsql-general |
The first part of the following piece of code should, and does, take an array of 5 characters and convert it to an escaped string of 10 characters (including the terminating byte). However, when going in the other direction PQunescapeBytea reports (in unescaped_len) that the resulting binary data has a length of 8 instead of 5 and is different than a[]. Am I using the escape/unescape functions incorrectly? I was expecting the unescape function to produce an exact duplicate of a[]. Thanks, Iker ======================== unsigned char a[5]; a[0] = 'a'; a[1] = 'a'; a[2] = 'a'; a[3] = 'a'; a[4] = 0; for (unsigned int i = 0; i < 5; ++i) printf("%c\n", a[i]); size_t escaped_len; size_t unescaped_len; unsigned char* escaped = PQescapeBytea(a, 5, &escaped_len); unsigned char* unescaped = PQunescapeBytea(escaped, &unescaped_len); printf("\n"); printf("unescaped_len: %d\n", unescaped_len); for (unsigned int i = 0; i < unescaped_len; ++i) printf("%c\n", unescaped[i]); ======================== OUTPUT: a a a a @ <== this is an unprintable character unescaped_len: 8 a a a a \ 0 0 0
В списке pgsql-general по дате отправления: