Skip to content
Commits on Source (40)
jcodings (1.0.32-1) unstable; urgency=medium
* New upstream release
* debian/rules
- drop unnecessary get-orig-source target
- convert build system from cdbs to dh
* debian/control
- set Standards-Version: 4.2.1 without changes
- drop Build-Depends: cdbs
- set Build-Depends: debhelper (>= 11)
- use maintainer address: pkg-java-maintainers@alioth-lists.debian.net
* debian/compat
- set 11
-- Hideki Yamane <henrich@debian.org> Mon, 17 Sep 2018 18:24:04 +0900
jcodings (1.0.30-2) unstable; urgency=medium
* Update Vcs-* to use salsa.debian.org
......
Source: jcodings
Section: java
Priority: optional
Maintainer: Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>
Maintainer: Debian Java Maintainers <pkg-java-maintainers@alioth-lists.debian.net>
Uploaders: Torsten Werner <twerner@debian.org>, Hideki Yamane <henrich@debian.org>
Build-Depends: default-jdk, debhelper (>= 10), cdbs, maven-debian-helper
Build-Depends: default-jdk, debhelper (>= 11), maven-debian-helper
Build-Depends-Indep: junit4 (>= 4.10)
Standards-Version: 4.1.4
Standards-Version: 4.2.1
Vcs-Git: https://salsa.debian.org/java-team/jcodings.git
Vcs-Browser: https://salsa.debian.org/java-team/jcodings
Homepage: https://github.com/jruby/jcodings
......
#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/maven.mk
JAVA_HOME := /usr/lib/jvm/default-java
get-orig-source:
uscan --download-version $(DEB_UPSTREAM_VERSION) --force-download --rename
%:
dh $@ --buildsystem=maven
......@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jruby.jcodings</groupId>
<artifactId>jcodings</artifactId>
<version>1.0.30</version>
<version>1.0.32</version>
<name>JCodings</name>
<description>
Byte based encoding support library for java
......
......@@ -25,4 +25,6 @@ public class UnicodeProperties {
static final CodeRangeEntry[]CodeRangeTable = new CodeRangeEntry[] {
%{extcrs}
};
static final int MAX_WORD_LENGTH = %{max_length};
}
......@@ -180,9 +180,10 @@ def generate_coderange_list
name = "#{$1}=#{$2}" if name =~ /(graphemeclusterbreak)(.*)/i
([name] + aliases[name].to_a).map{|n|[n, range]}
end.flatten(1)
max_length = out.max_by{|name, table|name.length}.first.length.to_s
open("#{SRC_DIR}/unicode/UnicodeProperties.java", "wb") do |f| f <<
open("UnicodePropertiesTemplate.java", "rb").read.sub(/%\{extcrs\}/, out.map{|name, table| "#{INDENT * 2}" + "new CodeRangeEntry(\"#{name}\", \"CR_#{table}\")"}.join(",\n"))
open("UnicodePropertiesTemplate.java", "rb").read.sub(/%\{max_length\}/, max_length).sub(/%\{extcrs\}/, out.map{|name, table| "#{INDENT * 2}" + "new CodeRangeEntry(\"#{name}\", \"CR_#{table}\")"}.join(",\n"))
end
end
......
......@@ -50,7 +50,7 @@ abstract class AbstractEncoding extends Encoding {
*/
@Override
public boolean isNewLine(byte[]bytes, int p, int end) {
return p < end ? bytes[p] == (byte)0x0a : false;
return p < end ? bytes[p] == Encoding.NEW_LINE : false;
}
protected final int asciiMbcCaseFold(int flag, byte[]bytes, IntHolder pp, int end, byte[]lower) {
......@@ -134,11 +134,28 @@ abstract class AbstractEncoding extends Encoding {
return toP - toStart;
}
@Override
public int caseMap(IntHolder flagP, byte[] bytes, IntHolder pp, int end, byte[] to, int toP, int toEnd) {
return asciiOnlyCaseMap(flagP, bytes, pp, end, to, toP, toEnd);
}
int singleByteAsciiOnlyCaseMap(IntHolder flagP, byte[]bytes, IntHolder pp, int end, byte[]to, int toP, int toEnd) {
int toStart = toP;
int flags = flagP.value;
while (pp.value < end && toP < toEnd) {
int code = bytes[pp.value++] & 0xff;
if (code >= 'a' && code <= 'z' && ((flags & Config.CASE_UPCASE) != 0)) {
flags |= Config.CASE_MODIFIED;
code += 'A' - 'a';
} else if (code >= 'A' && code <= 'Z' && ((flags & (Config.CASE_DOWNCASE | Config.CASE_FOLD)) != 0)) {
flags |= Config.CASE_MODIFIED;
code += 'a' - 'A';
}
to[toP++] = (byte)code;
if ((flags & Config.CASE_TITLECASE) != 0) {
flags ^= (Config.CASE_UPCASE | Config.CASE_DOWNCASE | Config.CASE_TITLECASE);
}
}
flagP.value = flags;
return toP - toStart;
}
/** onigenc_minimum_property_name_to_ctype
* notably overridden by unicode encodings
......@@ -147,6 +164,6 @@ abstract class AbstractEncoding extends Encoding {
public int propertyNameToCType(byte[]bytes, int p, int end) {
Integer ctype = PosixBracket.PBSTableUpper.get(bytes, p, end);
if (ctype != null) return ctype;
throw new CharacterPropertyException(EncodingError.ERR_INVALID_CHAR_PROPERTY_NAME, new String(bytes, p, end - p));
throw new CharacterPropertyException(EncodingError.ERR_INVALID_CHAR_PROPERTY_NAME, bytes, p, end - p);
}
}
......@@ -122,6 +122,11 @@ public abstract class MultiByteEncoding extends AbstractEncoding {
return n;
}
@Override
public int caseMap(IntHolder flagP, byte[] bytes, IntHolder pp, int end, byte[] to, int toP, int toEnd) {
return asciiOnlyCaseMap(flagP, bytes, pp, end, to, toP, toEnd);
}
protected final int mbnMbcCaseFold(int flag, byte[]bytes, IntHolder pp, int end, byte[]lower) {
int p = pp.value;
int lowerP = 0;
......
......@@ -54,6 +54,11 @@ public abstract class SingleByteEncoding extends AbstractEncoding {
}
// onigenc_is_mbc_newline_0x0a here
@Override
public int caseMap(IntHolder flagP, byte[] bytes, IntHolder pp, int end, byte[] to, int toP, int toEnd) {
return singleByteAsciiOnlyCaseMap(flagP, bytes, pp, end, to, toP, toEnd);
}
/** onigenc_single_byte_mbc_to_code
*/
@Override
......
......@@ -24,18 +24,17 @@ import org.jcodings.IntHolder;
import org.jcodings.ascii.AsciiTables;
public abstract class BaseBIG5Encoding extends CanBeTrailTableEncoding {
private final int transIndex;
private final int[]TransBase;
protected BaseBIG5Encoding(String name, int[]EncLen, int transIndex) {
super(name, 1, 2, EncLen, BIG5Trans, AsciiTables.AsciiCtypeTable, BIG5_CAN_BE_TRAIL_TABLE);
this.transIndex = transIndex;
TransBase = Trans[transIndex];
}
@Override
public int length(byte[]bytes, int p, int end) {
int b = bytes[p++] & 0xff;
int s = Trans[transIndex][b];
int s = TransBase[b];
if (s < 0) return s == A ? 1 : CHAR_INVALID;
if (p == end) return missing(EncLen[b] - 1);
s = Trans[s][bytes[p] & 0xff];
......
......@@ -19,7 +19,10 @@
*/
package org.jcodings.specific;
import org.jcodings.Config;
import org.jcodings.ISOEncoding;
import org.jcodings.IntHolder;
import org.jcodings.constants.CharacterType;
public final class ISO8859_10Encoding extends ISOEncoding {
......@@ -27,6 +30,44 @@ public final class ISO8859_10Encoding extends ISOEncoding {
super("ISO-8859-10", ISO8859_10CtypeTable, ISO8859_10ToLowerCaseTable, ISO8859_10CaseFoldMap);
}
@Override
public int caseMap(IntHolder flagP, byte[] bytes, IntHolder pp, int end, byte[] to, int toP, int toEnd) {
int toStart = toP;
int flags = flagP.value;
while (pp.value < end && toP < toEnd) {
int code = bytes[pp.value++] & 0xff;
if (code == SHARP_s) {
if ((flags & Config.CASE_UPCASE) != 0) {
flags |= Config.CASE_MODIFIED;
to[toP++] = 'S';
code = (flags & Config.CASE_TITLECASE) != 0 ? 's' : 'S';
} else if ((flags & Config.CASE_FOLD) != 0) {
flags |= Config.CASE_MODIFIED;
to[toP++] = 's';
code = 's';
}
} else if (code == 0xBD || code == 0xFF) {
} else if ((ISO8859_10CtypeTable[code] & CharacterType.BIT_UPPER) != 0 && (flags & (Config.CASE_DOWNCASE | Config.CASE_FOLD)) != 0) {
flags |= Config.CASE_MODIFIED;
code = LowerCaseTable[code];
} else if ((ISO8859_10CtypeTable[code] & CharacterType.BIT_LOWER) != 0 && (flags & Config.CASE_UPCASE) != 0) {
flags |= Config.CASE_MODIFIED;
if (code >= 0xA0 && code <= 0xBF) {
code -= 0x10;
} else {
code -= 0x20;
}
}
to[toP++] = (byte)code;
if ((flags & Config.CASE_TITLECASE) != 0) {
flags ^= (Config.CASE_UPCASE | Config.CASE_DOWNCASE | Config.CASE_TITLECASE);
}
}
flagP.value = flags;
return toP - toStart;
}
static final short ISO8859_10CtypeTable[] = {
0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
......
......@@ -19,7 +19,10 @@
*/
package org.jcodings.specific;
import org.jcodings.Config;
import org.jcodings.ISOEncoding;
import org.jcodings.IntHolder;
import org.jcodings.constants.CharacterType;
public final class ISO8859_13Encoding extends ISOEncoding {
......@@ -27,6 +30,45 @@ public final class ISO8859_13Encoding extends ISOEncoding {
super("ISO-8859-13", ISO8859_13CtypeTable, ISO8859_13ToLowerCaseTable, ISO8859_13CaseFoldMap);
}
@Override
public int caseMap(IntHolder flagP, byte[] bytes, IntHolder pp, int end, byte[] to, int toP, int toEnd) {
int toStart = toP;
int flags = flagP.value;
while (pp.value < end && toP < toEnd) {
int code = bytes[pp.value++] & 0xff;
if (code == SHARP_s) {
if ((flags & Config.CASE_UPCASE) != 0) {
flags |= Config.CASE_MODIFIED;
to[toP++] = 'S';
code = (flags & Config.CASE_TITLECASE) != 0 ? 's' : 'S';
} else if ((flags & Config.CASE_FOLD) != 0) {
flags |= Config.CASE_MODIFIED;
to[toP++] = 's';
code = 's';
}
} else if ((ISO8859_13CtypeTable[code] & CharacterType.BIT_UPPER) != 0 && (flags & (Config.CASE_DOWNCASE | Config.CASE_FOLD)) != 0) {
flags |= Config.CASE_MODIFIED;
code = LowerCaseTable[code];
} else if (code == 0xB5) {
} else if ((ISO8859_13CtypeTable[code] & CharacterType.BIT_LOWER) != 0 && (flags & Config.CASE_UPCASE) != 0) {
flags |= Config.CASE_MODIFIED;
if (code == 0xB8 || code == 0xBA || code == 0xBF) {
code -= 0x10;
} else {
code -= 0x20;
}
}
to[toP++] = (byte)code;
if ((flags & Config.CASE_TITLECASE) != 0) {
flags ^= (Config.CASE_UPCASE | Config.CASE_DOWNCASE | Config.CASE_TITLECASE);
}
}
flagP.value = flags;
return toP - toStart;
}
static final short ISO8859_13CtypeTable[] = {
0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
......
......@@ -19,7 +19,10 @@
*/
package org.jcodings.specific;
import org.jcodings.Config;
import org.jcodings.ISOEncoding;
import org.jcodings.IntHolder;
import org.jcodings.constants.CharacterType;
public final class ISO8859_14Encoding extends ISOEncoding {
......@@ -27,6 +30,52 @@ public final class ISO8859_14Encoding extends ISOEncoding {
super("ISO-8859-14", ISO8859_14CtypeTable, ISO8859_14ToLowerCaseTable, ISO8859_14CaseFoldMap);
}
@Override
public int caseMap(IntHolder flagP, byte[] bytes, IntHolder pp, int end, byte[] to, int toP, int toEnd) {
int toStart = toP;
int flags = flagP.value;
while (pp.value < end && toP < toEnd) {
int code = bytes[pp.value++] & 0xff;
if (code == SHARP_s) {
if ((flags & Config.CASE_UPCASE) != 0) {
flags |= Config.CASE_MODIFIED;
to[toP++] = 'S';
code = (flags & Config.CASE_TITLECASE) != 0 ? 's' : 'S';
} else if ((flags & Config.CASE_FOLD) != 0) {
flags |= Config.CASE_MODIFIED;
to[toP++] = 's';
code = 's';
}
} else if ((ISO8859_14CtypeTable[code] & CharacterType.BIT_UPPER) != 0 && (flags & (Config.CASE_DOWNCASE | Config.CASE_FOLD)) != 0) {
flags |= Config.CASE_MODIFIED;
code = LowerCaseTable[code];
} else if ((ISO8859_14CtypeTable[code] & CharacterType.BIT_LOWER) != 0 && (flags & Config.CASE_UPCASE) != 0) {
flags |= Config.CASE_MODIFIED;
if (code == 0xA2 || code == 0xA5 || code == 0xB1 || code == 0xB3 || code == 0xB5 || code == 0xBE)
code -= 0x1;
else if (code == 0xAB)
code -= 0x5;
else if (code == 0xFF)
code -= 0x50;
else if (code == 0xB9)
code -= 0x2;
else if (code == 0xBF)
code -= 0x4;
else if (code == 0xB8 || code == 0xBA || code == 0xBC)
code -= 0x10;
else
code -= 0x20;
}
to[toP++] = (byte)code;
if ((flags & Config.CASE_TITLECASE) != 0) {
flags ^= (Config.CASE_UPCASE | Config.CASE_DOWNCASE | Config.CASE_TITLECASE);
}
}
flagP.value = flags;
return toP - toStart;
}
static final short ISO8859_14CtypeTable[] = {
0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
......
......@@ -19,7 +19,10 @@
*/
package org.jcodings.specific;
import org.jcodings.Config;
import org.jcodings.ISOEncoding;
import org.jcodings.IntHolder;
import org.jcodings.constants.CharacterType;
public final class ISO8859_15Encoding extends ISOEncoding {
......@@ -27,6 +30,49 @@ public final class ISO8859_15Encoding extends ISOEncoding {
super("ISO-8859-15", ISO8859_15CtypeTable, ISO8859_15ToLowerCaseTable, ISO8859_15CaseFoldMap);
}
@Override
public int caseMap(IntHolder flagP, byte[] bytes, IntHolder pp, int end, byte[] to, int toP, int toEnd) {
int toStart = toP;
int flags = flagP.value;
while (pp.value < end && toP < toEnd) {
int code = bytes[pp.value++] & 0xff;
if (code == SHARP_s) {
if ((flags & Config.CASE_UPCASE) != 0) {
flags |= Config.CASE_MODIFIED;
to[toP++] = 'S';
code = (flags & Config.CASE_TITLECASE) != 0 ? 's' : 'S';
} else if ((flags & Config.CASE_FOLD) != 0) {
flags |= Config.CASE_MODIFIED;
to[toP++] = 's';
code = 's';
}
} else if (code == 0xAA || code == 0xBA || code == 0xB5) {
} else if ((ISO8859_15CtypeTable[code] & CharacterType.BIT_UPPER) != 0 && (flags & (Config.CASE_DOWNCASE | Config.CASE_FOLD)) != 0) {
flags |= Config.CASE_MODIFIED;
code = LowerCaseTable[code];
} else if ((ISO8859_15CtypeTable[code] & CharacterType.BIT_LOWER) != 0 && (flags & Config.CASE_UPCASE) != 0) {
flags |= Config.CASE_MODIFIED;
if (code == 0xA8)
code -= 2;
else if (code == 0xB8)
code -= 4;
else if (code == 0xBD)
code -= 1;
else if (code == 0xFF)
code -= 0x41;
else
code -= 0x20;
}
to[toP++] = (byte)code;
if ((flags & Config.CASE_TITLECASE) != 0) {
flags ^= (Config.CASE_UPCASE | Config.CASE_DOWNCASE | Config.CASE_TITLECASE);
}
}
flagP.value = flags;
return toP - toStart;
}
static final short ISO8859_15CtypeTable[] = {
0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
......
......@@ -19,7 +19,10 @@
*/
package org.jcodings.specific;
import org.jcodings.Config;
import org.jcodings.ISOEncoding;
import org.jcodings.IntHolder;
import org.jcodings.constants.CharacterType;
public final class ISO8859_16Encoding extends ISOEncoding {
......@@ -27,6 +30,52 @@ public final class ISO8859_16Encoding extends ISOEncoding {
super("ISO-8859-16", ISO8859_16CtypeTable, ISO8859_16ToLowerCaseTable, ISO8859_16CaseFoldMap);
}
@Override
public int caseMap(IntHolder flagP, byte[] bytes, IntHolder pp, int end, byte[] to, int toP, int toEnd) {
int toStart = toP;
int flags = flagP.value;
while (pp.value < end && toP < toEnd) {
int code = bytes[pp.value++] & 0xff;
if (code == SHARP_s) {
if ((flags & Config.CASE_UPCASE) != 0) {
flags |= Config.CASE_MODIFIED;
to[toP++] = 'S';
code = (flags & Config.CASE_TITLECASE) != 0 ? 's' : 'S';
} else if ((flags & Config.CASE_FOLD) != 0) {
flags |= Config.CASE_MODIFIED;
to[toP++] = 's';
code = 's';
}
} else if ((ISO8859_16CtypeTable[code] & CharacterType.BIT_UPPER) != 0 && (flags & (Config.CASE_DOWNCASE | Config.CASE_FOLD)) != 0) {
flags |= Config.CASE_MODIFIED;
code = LowerCaseTable[code];
} else if ((ISO8859_16CtypeTable[code] & CharacterType.BIT_LOWER) != 0 && (flags & Config.CASE_UPCASE) != 0) {
flags |= Config.CASE_MODIFIED;
if (code == 0xA2 || code == 0xBD)
code--;
else if (code == 0xB3 || code == 0xBA || code == 0xBF)
code -= 0x10;
else if (code == 0xA8 || code == 0xAE)
code -= 0x02;
else if (code == 0xB9)
code -= 0x07;
else if (code == 0xB8)
code -= 0x04;
else if (code == 0xFF)
code -= 0x41;
else
code -= 0x20;
}
to[toP++] = (byte)code;
if ((flags & Config.CASE_TITLECASE) != 0) {
flags ^= (Config.CASE_UPCASE | Config.CASE_DOWNCASE | Config.CASE_TITLECASE);
}
}
flagP.value = flags;
return toP - toStart;
}
static final short ISO8859_16CtypeTable[] = {
0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
......
......@@ -30,8 +30,8 @@ public final class ISO8859_3Encoding extends ISOEncoding {
super("ISO-8859-3", ISO8859_3CtypeTable, ISO8859_3ToLowerCaseTable, ISO8859_3CaseFoldMap);
}
static final int DOTLESS_i = 0xFD;
static final int I_WITH_DOT_ABOVE = 0xDD;
static final int DOTLESS_i = 0xB9;
static final int I_WITH_DOT_ABOVE = 0xA9;
@Override
public int caseMap(IntHolder flagP, byte[] bytes, IntHolder pp, int end, byte[] to, int toP, int toEnd) {
......@@ -62,7 +62,7 @@ public final class ISO8859_3Encoding extends ISOEncoding {
} else if ((ISO8859_3CtypeTable[code] & CharacterType.BIT_LOWER) != 0 && (flags & Config.CASE_UPCASE) != 0) {
flags |= Config.CASE_MODIFIED;
if (code == 'i') {
code = (flags & Config.CASE_FOLD_TURKISH_AZERI) != 0 ? DOTLESS_i : 'I';
code = (flags & Config.CASE_FOLD_TURKISH_AZERI) != 0 ? I_WITH_DOT_ABOVE : 'I';
} else if (code == DOTLESS_i) {
code = 'I';
} else if (code >= 0xB0 && code <= 0xBF) {
......
......@@ -19,7 +19,10 @@
*/
package org.jcodings.specific;
import org.jcodings.Config;
import org.jcodings.ISOEncoding;
import org.jcodings.IntHolder;
import org.jcodings.constants.CharacterType;
public final class ISO8859_4Encoding extends ISOEncoding {
......@@ -27,6 +30,47 @@ public final class ISO8859_4Encoding extends ISOEncoding {
super("ISO-8859-4", ISO8859_4CtypeTable, ISO8859_4ToLowerCaseTable, ISO8859_4CaseFoldMap);
}
@Override
public int caseMap(IntHolder flagP, byte[] bytes, IntHolder pp, int end, byte[] to, int toP, int toEnd) {
int toStart = toP;
int flags = flagP.value;
while (pp.value < end && toP < toEnd) {
int code = bytes[pp.value++] & 0xff;
if (code == SHARP_s) {
if ((flags & Config.CASE_UPCASE) != 0) {
flags |= Config.CASE_MODIFIED;
to[toP++] = 'S';
code = (flags & Config.CASE_TITLECASE) != 0 ? 's' : 'S';
} else if ((flags & Config.CASE_FOLD) != 0) {
flags |= Config.CASE_MODIFIED;
to[toP++] = 's';
code = 's';
}
} else if ((ISO8859_4CtypeTable[code] & CharacterType.BIT_UPPER) != 0 && (flags & (Config.CASE_DOWNCASE | Config.CASE_FOLD)) != 0) {
flags |= Config.CASE_MODIFIED;
code = LowerCaseTable[code];
} else if (code == 0xA2) {
} else if ((ISO8859_4CtypeTable[code] & CharacterType.BIT_LOWER) != 0 && (flags & Config.CASE_UPCASE) != 0) {
flags |= Config.CASE_MODIFIED;
if (code >= 0xA0 && code <= 0xBF) {
if (code == 0xBF)
code -= 0x02;
else
code -= 0x10;
} else {
code -= 0x20;
}
}
to[toP++] = (byte)code;
if ((flags & Config.CASE_TITLECASE) != 0) {
flags ^= (Config.CASE_UPCASE | Config.CASE_DOWNCASE | Config.CASE_TITLECASE);
}
}
flagP.value = flags;
return toP - toStart;
}
static final short ISO8859_4CtypeTable[] = {
0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
......
......@@ -19,8 +19,10 @@
*/
package org.jcodings.specific;
import org.jcodings.Config;
import org.jcodings.ISOEncoding;
import org.jcodings.IntHolder;
import org.jcodings.constants.CharacterType;
public final class ISO8859_5Encoding extends ISOEncoding {
......@@ -28,6 +30,34 @@ public final class ISO8859_5Encoding extends ISOEncoding {
super("ISO-8859-5", ISO8859_5CtypeTable, ISO8859_5ToLowerCaseTable, ISO8859_5CaseFoldMap, false);
}
@Override
public int caseMap(IntHolder flagP, byte[] bytes, IntHolder pp, int end, byte[] to, int toP, int toEnd) {
int toStart = toP;
int flags = flagP.value;
while (pp.value < end && toP < toEnd) {
int code = bytes[pp.value++] & 0xff;
if ((ISO8859_5CtypeTable[code] & CharacterType.BIT_UPPER) != 0 && (flags & (Config.CASE_DOWNCASE | Config.CASE_FOLD)) != 0) {
flags |= Config.CASE_MODIFIED;
code = LowerCaseTable[code];
} else if ((ISO8859_5CtypeTable[code] & CharacterType.BIT_LOWER) != 0 && (flags & Config.CASE_UPCASE) != 0) {
flags |= Config.CASE_MODIFIED;
if (0xF1 <= code && code <= 0xFF) {
code -= 0x50;
} else {
code -= 0x20;
}
}
to[toP++] = (byte)code;
if ((flags & Config.CASE_TITLECASE) != 0) {
flags ^= (Config.CASE_UPCASE | Config.CASE_DOWNCASE | Config.CASE_TITLECASE);
}
}
flagP.value = flags;
return toP - toStart;
}
@Override
public int mbcCaseFold(int flag, byte[]bytes, IntHolder pp, int end, byte[]lower) {
int p = pp.value;
......@@ -141,7 +171,7 @@ public final class ISO8859_5Encoding extends ISOEncoding {
{ 0xbb, 0xdb },
{ 0xbc, 0xdc },
{ 0xbd, 0xdd },
{ 0xbe, 0xdf },
{ 0xbe, 0xde },
{ 0xbf, 0xdf },
{ 0xc0, 0xe0 },
......
......@@ -19,8 +19,10 @@
*/
package org.jcodings.specific;
import org.jcodings.Config;
import org.jcodings.ISOEncoding;
import org.jcodings.IntHolder;
import org.jcodings.constants.CharacterType;
public final class ISO8859_7Encoding extends ISOEncoding {
......@@ -28,6 +30,49 @@ public final class ISO8859_7Encoding extends ISOEncoding {
super("ISO-8859-7", ISO8859_7CtypeTable, ISO8859_7ToLowerCaseTable, ISO8859_7CaseFoldMap, false);
}
@Override
public int caseMap(IntHolder flagP, byte[] bytes, IntHolder pp, int end, byte[] to, int toP, int toEnd) {
int toStart = toP;
int flags = flagP.value;
while (pp.value < end && toP < toEnd) {
int code = bytes[pp.value++] & 0xff;
if (code == 0xF2) {
if ((flags & Config.CASE_UPCASE) != 0) {
flags |= Config.CASE_MODIFIED;
code = 0xD3;
} else if ((flags & Config.CASE_FOLD) != 0) {
flags |= Config.CASE_MODIFIED;
code = 0xF3;
}
} else if ((ISO8859_7CtypeTable[code] & CharacterType.BIT_UPPER) != 0 && (flags & (Config.CASE_DOWNCASE | Config.CASE_FOLD)) != 0) {
flags |= Config.CASE_MODIFIED;
code = LowerCaseTable[code];
} else if (code == 0xC0 || code == 0xE0) {
} else if ((ISO8859_7CtypeTable[code] & CharacterType.BIT_LOWER) != 0 && (flags & Config.CASE_UPCASE) != 0) {
flags |= Config.CASE_MODIFIED;
if (code == 0xDC) {
code -= 0x26;
} else if (code >= 0xDD && code <= 0xDF) {
code -= 0x25;
} else if (code == 0xFC) {
code -= 0x40;
} else if (code == 0xFD || code == 0xFE) {
code -= 0x3F;
} else {
code -= 0x20;
}
}
to[toP++] = (byte)code;
if ((flags & Config.CASE_TITLECASE) != 0) {
flags ^= (Config.CASE_UPCASE | Config.CASE_DOWNCASE | Config.CASE_TITLECASE);
}
}
flagP.value = flags;
return toP - toStart;
}
@Override
public int mbcCaseFold(int flag, byte[]bytes, IntHolder pp, int end, byte[]lower) {
int p = pp.value;
......