/** * This sample software accompanies Unicode Technical Report #6 and * distributed as is by Unicode, Inc., subject to the following: * * Copyright © 1996-1997 Unicode, Inc.. All Rights Reserved. * * Permission to use, copy, modify, and distribute this software * without fee is hereby granted provided that this copyright notice * appears in all copies. * * UNICODE, INC. MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. * UNICODE, INC., SHALL NOT BE LIABLE FOR ANY ERRORS OR OMISSIONS, AND * SHALL NOT BE LIABLE FOR ANY DAMAGES, INCLUDING CONSEQUENTIAL AND * INCIDENTAL DAMAGES, SUFFERED BY YOU AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. * * @author Asmus Freytag * * @version 001 Dec 25 1996 * @version 002 Jun 25 1997 * @version 003 Jul 25 1997 * @version 004 Aug 25 1997 * * Unicode and the Unicode logo are trademarks of Unicode, Inc., * and are registered in some jurisdictions. **/ /** * A number of helpful output routines for debugging. Output can be * centrally enabled or disabled by calling Debug.set(true/false); * All methods are statics; */ public class Debug { static boolean debug = false; public static void set(boolean debug) { Debug.debug = debug; } // debugging helper public static void out(char [] chars) { out(chars, 0); } public static void out(char [] chars, int iStart) { if (!debug) return; for (int i = iStart; i < chars.length; i++) { if (chars[i] >= 0 && chars[i] <= 26) { System.out.print("^"+(char)(chars[i]+0x40)); } else if (chars[i] <= 255) { System.out.print(chars[i]); } else { System.out.print("\\u"+Integer.toString(chars[i],16)); } } System.out.println(); } public static void out(byte [] bytes) { out(bytes, 0); } public static void out(byte [] bytes, int iStart) { if (!debug) return; for (int i = iStart; i < bytes.length; i++) { System.out.print(bytes[i]+","); } System.out.println(); } public static void out(String str) { if (!debug) return; System.out.println(str); } public static void out(String msg, int iData) { if (!debug) return; System.out.print(msg); System.out.println(iData); } public static void out(String msg, char ch) { if (!debug) return; System.out.print(msg); System.out.print("[U+"+Integer.toString(ch,16)+"]"); System.out.println(ch); } public static void out(String msg, byte bData) { if (!debug) return; System.out.print(msg); System.out.println(bData); } public static void out(String msg, String str) { if (!debug) return; System.out.print(msg); System.out.println(str); } public static void out(String msg, char [] data) { if (!debug) return; System.out.print(msg); out(data); } public static void out(String msg, byte [] data) { if (!debug) return; System.out.print(msg); out(data); } public static void out(String msg, char [] data, int iStart) { if (!debug) return; System.out.print(msg +"("+iStart+"): "); out(data, iStart); } public static void out(String msg, byte [] data, int iStart) { if (!debug) return; System.out.print(msg+"("+iStart+"): "); out(data, iStart); } }