Skip to content

Commit 2dbb0ab

Browse files
committed
Activate previously existing windows-1252 charset support
This needs some changes to moarvm to be in place first.
1 parent 53d43e8 commit 2dbb0ab

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

docs/ops.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ Output the given string to the filehandle, followed by a newline.
10591059
* `setencoding(Handle $fh, str $encoding)`
10601060

10611061
Set the encoding for the given handle. Valid encodings are: ascii,
1062-
iso-8859-1, utf8, utf16, and binary.
1062+
iso-8859-1, windows-1252, utf8, utf16, and binary.
10631063

10641064
## setinputlinesep
10651065
* `setinputlinesep(Handle $fh, str $sep)`

src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,8 @@ else if (encoding.equals("utf8"))
458458
cs = Charset.forName("UTF-8");
459459
else if (encoding.equals("utf16"))
460460
cs = Charset.forName("UTF-16");
461+
else if (encoding.equals("windows-1252"))
462+
cs = Charset.forName("windows-1252");
461463
else
462464
throw ExceptionHandling.dieInternal(tc,
463465
"Unsupported encoding " + encoding);
@@ -3698,6 +3700,9 @@ else if (encoding.equals("ascii")) {
36983700
else if (encoding.equals("iso-8859-1")) {
36993701
Buffers.stashBytes(tc, res, str.getBytes("ISO-8859-1"));
37003702
}
3703+
else if (encoding.equals("windows-1252")) {
3704+
Buffers.stashBytes(tc, res, str.getBytes("windows-1252"));
3705+
}
37013706
else if (encoding.equals("utf16")) {
37023707
short[] buffer = new short[str.length()];
37033708
for (int i = 0; i < str.length(); i++)
@@ -3763,6 +3768,9 @@ else if (encoding.equals("ascii")) {
37633768
else if (encoding.equals("iso-8859-1")) {
37643769
return decode8(buf, "ISO-8859-1", tc);
37653770
}
3771+
else if (encoding.equals("windows-1252")) {
3772+
return decode8(buf, "windows-1252", tc);
3773+
}
37663774
else if (encoding.equals("utf16") || encoding.equals("utf32")) {
37673775
int n = (int)buf.elems(tc);
37683776
StringBuilder sb = new StringBuilder(n);

0 commit comments

Comments
 (0)