Skip to content

Commit d09fffa

Browse files
committed
FIX: turned off CRLF/CR conversion to LF when converting binary to string
Related issue: metaeducation/rebol-issues#2336
1 parent 9190f1c commit d09fffa

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/core/s-unicode.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,9 @@ ConversionResult ConvertUTF8toUTF32 (
932932
REBSER *dst;
933933
REBINT size;
934934

935+
REBFLG ccr = FALSE; // in original R3-alpha if was TRUE
936+
//@@ https://github.com/rebol/rebol-issues/issues/2336
937+
935938
if (utf == -1) {
936939
utf = What_UTF(bp, len);
937940
if (utf) {
@@ -942,13 +945,13 @@ ConversionResult ConvertUTF8toUTF32 (
942945
}
943946

944947
if (utf == 0 || utf == 8) {
945-
size = Decode_UTF8((REBUNI*)Reset_Buffer(ser, len), bp, len, TRUE);
948+
size = Decode_UTF8((REBUNI*)Reset_Buffer(ser, len), bp, len, ccr);
946949
}
947950
else if (utf == -16 || utf == 16) {
948-
size = Decode_UTF16((REBUNI*)Reset_Buffer(ser, len/2 + 1), bp, len, utf < 0, TRUE);
951+
size = Decode_UTF16((REBUNI*)Reset_Buffer(ser, len/2 + 1), bp, len, utf < 0, ccr);
949952
}
950953
else if (utf == -32 || utf == 32) {
951-
size = Decode_UTF32((REBUNI*)Reset_Buffer(ser, len/4 + 1), bp, len, utf < 0, TRUE);
954+
size = Decode_UTF32((REBUNI*)Reset_Buffer(ser, len/4 + 1), bp, len, utf < 0, ccr);
952955
}
953956

954957
if (size < 0) {

src/tests/units/series-test.r3

+11
Original file line numberDiff line numberDiff line change
@@ -143,5 +143,16 @@ Rebol [
143143

144144
===end-group===
145145

146+
===start-group=== "STRING conversion"
147+
148+
--test-- "issues/2336"
149+
;@@ https://github.com/rebol/rebol-issues/issues/2336
150+
--assert "^M" = to-string to-binary "^M"
151+
--assert "^/" = to-string to-binary "^/"
152+
--assert "^M^/" = to-string to-binary "^M^/"
153+
--assert "^/^M" = to-string to-binary "^/^M"
154+
155+
===end-group===
156+
146157

147158
~~~end-file~~~

0 commit comments

Comments
 (0)