Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #236 from skids/windows-1252
Activate previously existing windows-1252 charset support
  • Loading branch information
FROGGS committed Apr 24, 2015
2 parents eec34ed + 2dbb0ab commit 08d257a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/ops.markdown
Expand Up @@ -1059,7 +1059,7 @@ Output the given string to the filehandle, followed by a newline.
* `setencoding(Handle $fh, str $encoding)`

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

## setinputlinesep
* `setinputlinesep(Handle $fh, str $sep)`
Expand Down
8 changes: 8 additions & 0 deletions src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -458,6 +458,8 @@ else if (encoding.equals("utf8"))
cs = Charset.forName("UTF-8");
else if (encoding.equals("utf16"))
cs = Charset.forName("UTF-16");
else if (encoding.equals("windows-1252"))
cs = Charset.forName("windows-1252");
else
throw ExceptionHandling.dieInternal(tc,
"Unsupported encoding " + encoding);
Expand Down Expand Up @@ -3698,6 +3700,9 @@ else if (encoding.equals("ascii")) {
else if (encoding.equals("iso-8859-1")) {
Buffers.stashBytes(tc, res, str.getBytes("ISO-8859-1"));
}
else if (encoding.equals("windows-1252")) {
Buffers.stashBytes(tc, res, str.getBytes("windows-1252"));
}
else if (encoding.equals("utf16")) {
short[] buffer = new short[str.length()];
for (int i = 0; i < str.length(); i++)
Expand Down Expand Up @@ -3763,6 +3768,9 @@ else if (encoding.equals("ascii")) {
else if (encoding.equals("iso-8859-1")) {
return decode8(buf, "ISO-8859-1", tc);
}
else if (encoding.equals("windows-1252")) {
return decode8(buf, "windows-1252", tc);
}
else if (encoding.equals("utf16") || encoding.equals("utf32")) {
int n = (int)buf.elems(tc);
StringBuilder sb = new StringBuilder(n);
Expand Down

0 comments on commit 08d257a

Please sign in to comment.