Skip to content

Commit

Permalink
GB2312 is a copy of EUC-KR in MRI. Fixes jruby/jruby#2312.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Mar 27, 2015
1 parent 4050406 commit d772f2b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/org/jcodings/EncodingDB.java
Expand Up @@ -138,7 +138,7 @@ public boolean isDummy() {
"UTF-32BE", "UTF32BE",
"UTF-32LE", "UTF32LE",
"Windows-1251", "CP1251",
"GB2312", "EUCKR", // done via rb_enc_register
"GB2312", "GB2312",
"Windows-31J", "Windows_31J" // TODO: Windows-31J is actually a variant of SJIS
};

Expand Down
8 changes: 6 additions & 2 deletions src/org/jcodings/specific/EUCKREncoding.java
Expand Up @@ -24,10 +24,14 @@
import org.jcodings.IntHolder;
import org.jcodings.ascii.AsciiTables;

public final class EUCKREncoding extends EucEncoding {
public class EUCKREncoding extends EucEncoding {

protected EUCKREncoding() {
super("EUC-KR", 1, 2, EUCKREncLen, EUCKRTrans, AsciiTables.AsciiCtypeTable);
this("EUC-KR");
}

protected EUCKREncoding(String name) {
super(name, 1, 2, EUCKREncLen, EUCKRTrans, AsciiTables.AsciiCtypeTable);
}

@Override
Expand Down
34 changes: 34 additions & 0 deletions src/org/jcodings/specific/GB2312Encoding.java
@@ -0,0 +1,34 @@
/*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.jcodings.specific;

import org.jcodings.Config;
import org.jcodings.EucEncoding;
import org.jcodings.IntHolder;
import org.jcodings.ascii.AsciiTables;

public final class GB2312Encoding extends EUCKREncoding {

protected GB2312Encoding() {
super("GB2312");
}

public static final GB2312Encoding INSTANCE = new GB2312Encoding();
}

1 comment on commit d772f2b

@nirvdrum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess making a copy wasn't as big of a hack as I thought :-)

Please sign in to comment.