mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
Improve "invalid byte sequence for encoding" message
It used to say ERROR: invalid byte sequence for encoding "UTF8": 0xdb24 Change this to ERROR: invalid byte sequence for encoding "UTF8": 0xdb 0x24 to make it clear that this is a byte sequence and not a code point. Also fix the adjacent "character has no equivalent" message that has the same issue.
This commit is contained in:
parent
7cb99b2696
commit
a2a5ce6826
@ -1595,7 +1595,7 @@ void
|
|||||||
report_invalid_encoding(int encoding, const char *mbstr, int len)
|
report_invalid_encoding(int encoding, const char *mbstr, int len)
|
||||||
{
|
{
|
||||||
int l = pg_encoding_mblen(encoding, mbstr);
|
int l = pg_encoding_mblen(encoding, mbstr);
|
||||||
char buf[8 * 2 + 1];
|
char buf[8 * 5 + 1];
|
||||||
char *p = buf;
|
char *p = buf;
|
||||||
int j,
|
int j,
|
||||||
jlimit;
|
jlimit;
|
||||||
@ -1604,11 +1604,15 @@ report_invalid_encoding(int encoding, const char *mbstr, int len)
|
|||||||
jlimit = Min(jlimit, 8); /* prevent buffer overrun */
|
jlimit = Min(jlimit, 8); /* prevent buffer overrun */
|
||||||
|
|
||||||
for (j = 0; j < jlimit; j++)
|
for (j = 0; j < jlimit; j++)
|
||||||
p += sprintf(p, "%02x", (unsigned char) mbstr[j]);
|
{
|
||||||
|
p += sprintf(p, "0x%02x", (unsigned char) mbstr[j]);
|
||||||
|
if (j < jlimit - 1)
|
||||||
|
p += sprintf(p, " ");
|
||||||
|
}
|
||||||
|
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
|
(errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
|
||||||
errmsg("invalid byte sequence for encoding \"%s\": 0x%s",
|
errmsg("invalid byte sequence for encoding \"%s\": %s",
|
||||||
pg_enc2name_tbl[encoding].name,
|
pg_enc2name_tbl[encoding].name,
|
||||||
buf)));
|
buf)));
|
||||||
}
|
}
|
||||||
@ -1624,7 +1628,7 @@ report_untranslatable_char(int src_encoding, int dest_encoding,
|
|||||||
const char *mbstr, int len)
|
const char *mbstr, int len)
|
||||||
{
|
{
|
||||||
int l = pg_encoding_mblen(src_encoding, mbstr);
|
int l = pg_encoding_mblen(src_encoding, mbstr);
|
||||||
char buf[8 * 2 + 1];
|
char buf[8 * 5 + 1];
|
||||||
char *p = buf;
|
char *p = buf;
|
||||||
int j,
|
int j,
|
||||||
jlimit;
|
jlimit;
|
||||||
@ -1633,11 +1637,15 @@ report_untranslatable_char(int src_encoding, int dest_encoding,
|
|||||||
jlimit = Min(jlimit, 8); /* prevent buffer overrun */
|
jlimit = Min(jlimit, 8); /* prevent buffer overrun */
|
||||||
|
|
||||||
for (j = 0; j < jlimit; j++)
|
for (j = 0; j < jlimit; j++)
|
||||||
p += sprintf(p, "%02x", (unsigned char) mbstr[j]);
|
{
|
||||||
|
p += sprintf(p, "0x%02x", (unsigned char) mbstr[j]);
|
||||||
|
if (j < jlimit - 1)
|
||||||
|
p += sprintf(p, " ");
|
||||||
|
}
|
||||||
|
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
|
(errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
|
||||||
errmsg("character 0x%s of encoding \"%s\" has no equivalent in \"%s\"",
|
errmsg("character with byte sequence %s in encoding \"%s\" has no equivalent in encoding \"%s\"",
|
||||||
buf,
|
buf,
|
||||||
pg_enc2name_tbl[src_encoding].name,
|
pg_enc2name_tbl[src_encoding].name,
|
||||||
pg_enc2name_tbl[dest_encoding].name)));
|
pg_enc2name_tbl[dest_encoding].name)));
|
||||||
|
Loading…
Reference in New Issue
Block a user