diff options
author | Karl Berry <karl@freefriends.org> | 2008-05-10 00:34:52 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2008-05-10 00:34:52 +0000 |
commit | 3faea455168abd154168997d2b79fe677fb2afa0 (patch) | |
tree | 8a2f7cc789389ed17d28d6a45053fb36db4c7b0b /Build/source/texk/tex4htk/java/xtpipes/XtpipesUni.java | |
parent | 3affd633834494c279f96078e95831935ea51ca7 (diff) |
missed new executables
git-svn-id: svn://tug.org/texlive/trunk@8001 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/tex4htk/java/xtpipes/XtpipesUni.java')
-rwxr-xr-x | Build/source/texk/tex4htk/java/xtpipes/XtpipesUni.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Build/source/texk/tex4htk/java/xtpipes/XtpipesUni.java b/Build/source/texk/tex4htk/java/xtpipes/XtpipesUni.java new file mode 100755 index 00000000000..7050d590d17 --- /dev/null +++ b/Build/source/texk/tex4htk/java/xtpipes/XtpipesUni.java @@ -0,0 +1,41 @@ +// 2008-01-26-00:38 +package xtpipes; +public class XtpipesUni{ + private static int D800 = Integer.parseInt("D800", 16); +private static int DFFF = Integer.parseInt("DFFF", 16); +private static int DC00 = Integer.parseInt("DC00", 16); +private static int X400 = Integer.parseInt("400",16); +private static int X10000 = Integer.parseInt("10000",16); + + +public static String toUni( char[] ch, int start, int length, + String filter ){ + StringBuffer buf = new StringBuffer(length); + for (int i = 0; i < length; i++) { + int chr = ch[ start + i ]; + boolean ascii = (chr == '\n') + || (chr > 31) && (chr < 127) ; + if( filter.indexOf(chr) > -1 ){ ascii = false; } + + if( (chr >= D800) && (chr<= DFFF) ){ + chr = ((ch[i] - D800) * X400 + (ch[++i] - DC00)) + X10000; + } + + + buf.append( + ascii ? Character.toString((char) chr) + : ("&#x" + + Integer.toHexString(chr).toUpperCase() + + ";" ) ); + } + return new String(buf); +} + + public static String toUni( String s, String filter ){ + char [] ch = s.toCharArray(); + int length = ch.length; + return toUni(ch, 0, length, filter); +} + +} + |