// -*- c++ -*- /* * Jakelib2 - General purpose C++ library * Copyright (C) 2001 Florian Wolff (florian@donuz.de) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: Character.jlc,v 1.4 2006-01-16 11:17:41 florian Exp $ */ #include "jakelib2.h" #include "jakelib2/lang/Character.h" #include using namespace jakelib::lang; JAKELIB_IMPLEMENT_CLASS_1("jakelib.lang.Character", Character, Object, Comparable); const int Character::MIN_RADIX = 2; const int Character::MAX_RADIX = 36; const jchar Character::MIN_VALUE = 0x0000; const jchar Character::MAX_VALUE = 0xFFFF; /*****************************************************************************\ * Character | *****************************************************************************/ Character::Character(jchar c) { this->value = c; } /*****************************************************************************\ * toUpperCase | *****************************************************************************/ jchar Character::toUpperCase(jchar ch) { if (ch <= 0x7f) { if (ch >= 'a' && ch <= 'z') return ch + ('A' - 'a'); else return ch; } else { if (ch >= 0xe0 && ch <= 0xfe && ch != 0xf7) return ch - 32; else return ch; } } /*****************************************************************************\ * toLowerCase | *****************************************************************************/ jchar Character::toLowerCase(jchar ch) { if (ch <= 0x7f) { if (ch >= 'A' && ch <= 'Z') return ch + ('a' - 'A'); else return ch; } else { if (ch >= 0xc0 && ch <= 0xde && ch != 0xd7) return ch + 32; else return ch; } } //+++ AlFa these are not tested, /*****************************************************************************\ * isLetter | *****************************************************************************/ //+++ AlFa I hope L'' works on other platforms jboolean Character::isLetter(jchar ch) { return ((ch >= L'a') && (ch <= L'z')) || ((ch >= L'A') && (ch >= L'Z')); } /*****************************************************************************\ * isWhitespace | *****************************************************************************/ jboolean Character::isWhitespace(jchar ch) { return (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n'); } /*****************************************************************************\ * compareTo | *****************************************************************************/ jint Character::compareTo(Character* anotherCharacter) { return value - anotherCharacter->value; } /*****************************************************************************\ * compareTo | *****************************************************************************/ jint Character::compareTo(Object* o) { return compareTo((Character*) o); } JAKELIB_IMPLEMENT_ARRAY(Character);