Skip to content

Commit b473271

Browse files
Merge pull request ClickHouse#88940 from ClickHouse/backport/25.8/88914
Backport ClickHouse#88914 to 25.8: Fix bug in `reverseUTF8`
2 parents 1d50502 + 3339b7b commit b473271

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/Functions/reverseUTF8.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct ReverseUTF8Impl
4646
ColumnString::Offset j = prev_offset;
4747
while (j < offsets[i])
4848
{
49-
if (data[j] < 0xBF)
49+
if (data[j] < 0xC0)
5050
{
5151
res_data[offsets[i] + prev_offset - 1 - j] = data[j];
5252
j += 1;
@@ -63,8 +63,8 @@ struct ReverseUTF8Impl
6363
}
6464
else
6565
{
66-
res_data[offsets[i] + prev_offset - 1 - j] = data[j];
67-
j += 1;
66+
memcpy(&res_data[offsets[i] + prev_offset - 1 - j - 3], &data[j], 4);
67+
j += 4;
6868
}
6969
}
7070

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
тівирп
2+
🌈🇧🇬
3+
🌈
4+
ेत्समन
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- The function reverses the sequence of UTF-8 code points (that is different from bytes or full characters):
2+
3+
SELECT reverseUTF8('привіт');
4+
SELECT reverseUTF8('🇬🇧🌈');
5+
SELECT reverseUTF8('🌈');
6+
SELECT reverseUTF8('नमस्ते');

0 commit comments

Comments
 (0)