Skip to content

Commit

Permalink
[66_13] Pad zero when convert U+0000 to U+000F to Herk
Browse files Browse the repository at this point in the history
  • Loading branch information
da-liii authored Oct 12, 2024
1 parent 3b9c0a5 commit 4c4e471
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
39 changes: 21 additions & 18 deletions TeXmacs/tests/66_13.scm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

(define (test-herk-0x)
(check (herk->utf8 (string #\x00)) => "`") ; U+0060
(check (utf8->herk "`") => (string #\x00))

(check (herk->utf8 (string #\x01)) => "´") ; U+00B4
(check (herk->utf8 (string #\x02)) => "ˆ") ; U+02C6
(check (herk->utf8 (string #\x03)) => "˜") ; U+02DC
Expand All @@ -21,24 +23,25 @@
(check (herk->utf8 (string #\x0E)) => "") ; U+2039
(check (herk->utf8 (string #\x0F)) => "") ; U+203A

(check (herk->utf8 "<#0>") => (string #\x00))
(check (herk->utf8 "<#F>") => (string #\x0F))
(check (utf8->herk (string #\x00)) => "<#0>")
(check (utf8->herk (string #\x01)) => "<#1>")
(check (utf8->herk (string #\x02)) => "<#2>")
(check (utf8->herk (string #\x03)) => "<#3>")
(check (utf8->herk (string #\x04)) => "<#4>")
(check (utf8->herk (string #\x05)) => "<#5>")
(check (utf8->herk (string #\x06)) => "<#6>")
(check (utf8->herk (string #\x07)) => "<#7>")
(check (utf8->herk (string #\x08)) => "<#8>")
(check (utf8->herk (string #\x09)) => "<#9>")
(check (utf8->herk (string #\x0A)) => "<#A>")
(check (utf8->herk (string #\x0B)) => "<#B>")
(check (utf8->herk (string #\x0C)) => "<#C>")
(check (utf8->herk (string #\x0D)) => "<#D>")
(check (utf8->herk (string #\x0E)) => "<#E>")
(check (utf8->herk (string #\x0F)) => "<#F>")
(check (herk->utf8 "<#00>") => (string #\x00))
(check (herk->utf8 "<#0F>") => (string #\x0F))
(check (utf8->herk "<#00>") => "<#00>")
(check (utf8->herk (string #\x00)) => "<#00>")
(check (utf8->herk (string #\x01)) => "<#01>")
(check (utf8->herk (string #\x02)) => "<#02>")
(check (utf8->herk (string #\x03)) => "<#03>")
(check (utf8->herk (string #\x04)) => "<#04>")
(check (utf8->herk (string #\x05)) => "<#05>")
(check (utf8->herk (string #\x06)) => "<#06>")
(check (utf8->herk (string #\x07)) => "<#07>")
(check (utf8->herk (string #\x08)) => "<#08>")
(check (utf8->herk (string #\x09)) => "<#09>")
(check (utf8->herk (string #\x0A)) => "<#0A>")
(check (utf8->herk (string #\x0B)) => "<#0B>")
(check (utf8->herk (string #\x0C)) => "<#0C>")
(check (utf8->herk (string #\x0D)) => "<#0D>")
(check (utf8->herk (string #\x0E)) => "<#0E>")
(check (utf8->herk (string #\x0F)) => "<#0F>")
)

(define (test-herk-1x)
Expand Down
Binary file added TeXmacs/tests/tmu/66_13_cork00.tmu
Binary file not shown.
9 changes: 8 additions & 1 deletion src/Data/String/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,14 @@ utf8_to_herk (string input) {
uint32_t code= decode_from_utf8 (input, i);
string s = input (start, i);
string r = apply (conv, s);
if (r == s && (code < 32 || code >= 128)) r= "<#" * to_Hex (code) * ">";
if (r == s) {
if (code < 16) {
r= "<#0" * to_Hex (code) * ">";
}
else if (code < 32 || code >= 128) {
r= "<#" * to_Hex (code) * ">";
}
}
output << r;
}
return output;
Expand Down

0 comments on commit 4c4e471

Please sign in to comment.