Skip to content

Commit 4c4e471

Browse files
authored
[66_13] Pad zero when convert U+0000 to U+000F to Herk
1 parent 3b9c0a5 commit 4c4e471

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

TeXmacs/tests/66_13.scm

+21-18
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
(define (test-herk-0x)
77
(check (herk->utf8 (string #\x00)) => "`") ; U+0060
8+
(check (utf8->herk "`") => (string #\x00))
9+
810
(check (herk->utf8 (string #\x01)) => "´") ; U+00B4
911
(check (herk->utf8 (string #\x02)) => "ˆ") ; U+02C6
1012
(check (herk->utf8 (string #\x03)) => "˜") ; U+02DC
@@ -21,24 +23,25 @@
2123
(check (herk->utf8 (string #\x0E)) => "") ; U+2039
2224
(check (herk->utf8 (string #\x0F)) => "") ; U+203A
2325

24-
(check (herk->utf8 "<#0>") => (string #\x00))
25-
(check (herk->utf8 "<#F>") => (string #\x0F))
26-
(check (utf8->herk (string #\x00)) => "<#0>")
27-
(check (utf8->herk (string #\x01)) => "<#1>")
28-
(check (utf8->herk (string #\x02)) => "<#2>")
29-
(check (utf8->herk (string #\x03)) => "<#3>")
30-
(check (utf8->herk (string #\x04)) => "<#4>")
31-
(check (utf8->herk (string #\x05)) => "<#5>")
32-
(check (utf8->herk (string #\x06)) => "<#6>")
33-
(check (utf8->herk (string #\x07)) => "<#7>")
34-
(check (utf8->herk (string #\x08)) => "<#8>")
35-
(check (utf8->herk (string #\x09)) => "<#9>")
36-
(check (utf8->herk (string #\x0A)) => "<#A>")
37-
(check (utf8->herk (string #\x0B)) => "<#B>")
38-
(check (utf8->herk (string #\x0C)) => "<#C>")
39-
(check (utf8->herk (string #\x0D)) => "<#D>")
40-
(check (utf8->herk (string #\x0E)) => "<#E>")
41-
(check (utf8->herk (string #\x0F)) => "<#F>")
26+
(check (herk->utf8 "<#00>") => (string #\x00))
27+
(check (herk->utf8 "<#0F>") => (string #\x0F))
28+
(check (utf8->herk "<#00>") => "<#00>")
29+
(check (utf8->herk (string #\x00)) => "<#00>")
30+
(check (utf8->herk (string #\x01)) => "<#01>")
31+
(check (utf8->herk (string #\x02)) => "<#02>")
32+
(check (utf8->herk (string #\x03)) => "<#03>")
33+
(check (utf8->herk (string #\x04)) => "<#04>")
34+
(check (utf8->herk (string #\x05)) => "<#05>")
35+
(check (utf8->herk (string #\x06)) => "<#06>")
36+
(check (utf8->herk (string #\x07)) => "<#07>")
37+
(check (utf8->herk (string #\x08)) => "<#08>")
38+
(check (utf8->herk (string #\x09)) => "<#09>")
39+
(check (utf8->herk (string #\x0A)) => "<#0A>")
40+
(check (utf8->herk (string #\x0B)) => "<#0B>")
41+
(check (utf8->herk (string #\x0C)) => "<#0C>")
42+
(check (utf8->herk (string #\x0D)) => "<#0D>")
43+
(check (utf8->herk (string #\x0E)) => "<#0E>")
44+
(check (utf8->herk (string #\x0F)) => "<#0F>")
4245
)
4346

4447
(define (test-herk-1x)

TeXmacs/tests/tmu/66_13_cork00.tmu

221 Bytes
Binary file not shown.

src/Data/String/converter.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,14 @@ utf8_to_herk (string input) {
371371
uint32_t code= decode_from_utf8 (input, i);
372372
string s = input (start, i);
373373
string r = apply (conv, s);
374-
if (r == s && (code < 32 || code >= 128)) r= "<#" * to_Hex (code) * ">";
374+
if (r == s) {
375+
if (code < 16) {
376+
r= "<#0" * to_Hex (code) * ">";
377+
}
378+
else if (code < 32 || code >= 128) {
379+
r= "<#" * to_Hex (code) * ">";
380+
}
381+
}
375382
output << r;
376383
}
377384
return output;

0 commit comments

Comments
 (0)