All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.enhydra.xml.io.ShiftJisCharacterSet Maven / Gradle / Ivy

The newest version!

/*
 * Enhydra Java Application Server Project
 * 
 * The contents of this file are subject to the Enhydra Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License on
 * the Enhydra web site ( http://www.enhydra.org/ ).
 * 
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 
 * the License for the specific terms governing rights and limitations
 * under the License.
 * 
 * The Initial Developer of the Enhydra Application Server is Lutris
 * Technologies, Inc. The Enhydra Application Server and portions created
 * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
 * All Rights Reserved.
 * 
 * Contributor(s):
 * 
 * $Id: ShiftJisCharacterSet.java,v 1.2 2003/06/29 05:58:48 jkjome Exp $
 */
package org.enhydra.xml.io;

/** 
 * Class that implements special character handling for Shift_JIS.
 * This detects invalid ranges so that they can be encoded by character
 * entity references.  
 * 

* Required to support i-mode Emoji characters. These are character codes * that represent symbols on i-mode phones. The characters codes are invalid * Shift-JIS character and must be encoded in HTML pages as numeric character * entity references. Special handling is required on formatting to detect * these characters. *

* See http://www.nttdocomo.com/i/tag/emoji/ for details. */ class ShiftJisCharacterSet extends CharacterSet { /** Constructor */ public ShiftJisCharacterSet(String name, int charSize, String mimePreferred, String[] aliases) { super(name, charSize, mimePreferred, aliases); } /** * @see CharacterSet#isValid */ public boolean isValid(char ch) { int byte1 = ((ch >> 8) & 0xFF); int byte2 = (ch & 0xFF); // FIXME: Right now, we just exclude the user defined range, // which will result them being encoded as char entity refs // This partial solution was done for safety, due to limited // time to develop tests. if (((0xF0 <= byte1) && (byte1 <= 0xFC)) && (((0x40 <= byte2) && (byte2 <= 0x7e)) || ((0x80 <= byte2) && (byte2 <= 0xFC)))) { // User defined range return false; } else { return true; // FIXME: see above } } /** * @see CharacterSet#sameValidCharRange */ public boolean sameValidCharRange(CharacterSet otherSet) { // Only valid if Shift_JIS (only one of these objects should // exists, so we can compare pointers). return (otherSet == this); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy