Skip to content

Commit

Permalink
add iso8859-7 caseMap
Browse files Browse the repository at this point in the history
  • Loading branch information
lopex committed Apr 18, 2018
1 parent c239f92 commit 6f27648
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/org/jcodings/specific/ISO8859_7Encoding.java
Expand Up @@ -19,15 +19,60 @@
*/
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 {

protected ISO8859_7Encoding() {
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;
Expand Down

0 comments on commit 6f27648

Please sign in to comment.