Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita2a5ce6

Browse files
committed
Improve "invalid byte sequence for encoding" message
It used to sayERROR: invalid byte sequence for encoding "UTF8": 0xdb24Change this toERROR: invalid byte sequence for encoding "UTF8": 0xdb 0x24to make it clear that this is a byte sequence and not a code point.Also fix the adjacent "character has no equivalent" message that hasthe same issue.
1 parent7cb99b2 commita2a5ce6

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

‎src/backend/utils/mb/wchar.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ void
15951595
report_invalid_encoding(intencoding,constchar*mbstr,intlen)
15961596
{
15971597
intl=pg_encoding_mblen(encoding,mbstr);
1598-
charbuf[8*2+1];
1598+
charbuf[8*5+1];
15991599
char*p=buf;
16001600
intj,
16011601
jlimit;
@@ -1604,11 +1604,15 @@ report_invalid_encoding(int encoding, const char *mbstr, int len)
16041604
jlimit=Min(jlimit,8);/* prevent buffer overrun */
16051605

16061606
for (j=0;j<jlimit;j++)
1607-
p+=sprintf(p,"%02x", (unsignedchar)mbstr[j]);
1607+
{
1608+
p+=sprintf(p,"0x%02x", (unsignedchar)mbstr[j]);
1609+
if (j<jlimit-1)
1610+
p+=sprintf(p," ");
1611+
}
16081612

16091613
ereport(ERROR,
16101614
(errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
1611-
errmsg("invalid byte sequence for encoding \"%s\":0x%s",
1615+
errmsg("invalid byte sequence for encoding \"%s\": %s",
16121616
pg_enc2name_tbl[encoding].name,
16131617
buf)));
16141618
}
@@ -1624,7 +1628,7 @@ report_untranslatable_char(int src_encoding, int dest_encoding,
16241628
constchar*mbstr,intlen)
16251629
{
16261630
intl=pg_encoding_mblen(src_encoding,mbstr);
1627-
charbuf[8*2+1];
1631+
charbuf[8*5+1];
16281632
char*p=buf;
16291633
intj,
16301634
jlimit;
@@ -1633,11 +1637,15 @@ report_untranslatable_char(int src_encoding, int dest_encoding,
16331637
jlimit=Min(jlimit,8);/* prevent buffer overrun */
16341638

16351639
for (j=0;j<jlimit;j++)
1636-
p+=sprintf(p,"%02x", (unsignedchar)mbstr[j]);
1640+
{
1641+
p+=sprintf(p,"0x%02x", (unsignedchar)mbstr[j]);
1642+
if (j<jlimit-1)
1643+
p+=sprintf(p," ");
1644+
}
16371645

16381646
ereport(ERROR,
16391647
(errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
1640-
errmsg("character0x%sof encoding \"%s\" has no equivalent in \"%s\"",
1648+
errmsg("characterwith byte sequence%sin encoding \"%s\" has no equivalent in encoding \"%s\"",
16411649
buf,
16421650
pg_enc2name_tbl[src_encoding].name,
16431651
pg_enc2name_tbl[dest_encoding].name)));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp