org.jpedal.fonts.EncodingGBK Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of OpenViewerFX Show documentation
Show all versions of OpenViewerFX Show documentation
Open Source (LGPL) JavaFX PDF Viewer
/*
* ===========================================
* Java Pdf Extraction Decoding Access Library
* ===========================================
*
* Project Info: http://www.idrsolutions.com
* Help section for developers at http://www.idrsolutions.com/support/
*
* (C) Copyright 1997-2017 IDRsolutions and Contributors.
*
* This file is part of JPedal/JPDF2HTML5
*
@LICENSE@
*
* ---------------
* EncodingGBK.java
* ---------------
*/
package org.jpedal.fonts;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import org.jpedal.utils.LogWriter;
/**
*
* @author suda
*/
public class EncodingGBK implements CmapEncoding {
private final int[] uniMap = new int[65536];
public EncodingGBK() {
final ClassLoader loader = this.getClass().getClassLoader();
String line;
int gbkVal, unicodeVal;
final BufferedReader input_stream;
try {
input_stream = new BufferedReader(
new InputStreamReader(loader.getResourceAsStream("org/jpedal/res/pdf/GBKtoUNI.cfg")));
while (true) {
line = input_stream.readLine();
if (line == null) {
break;
}
if (line.startsWith("0x")) {
final StringTokenizer values = new StringTokenizer(line);
final String xx = values.nextToken().substring(2);
final String yy = values.nextToken().substring(2);
gbkVal = Integer.parseInt(xx, 16);
unicodeVal = Integer.parseInt(yy, 16);
uniMap[gbkVal] = unicodeVal;
}
}
input_stream.close();
} catch (final Exception e) {
LogWriter.writeLog("Exception: " + e.getMessage());
}
}
@Override
public int getUnicodeValue(final int cid) {
if (cid <= 0x7f) {
return cid;
}
return uniMap[cid];
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy