00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "text/Char.h"
00026
00027 namespace Tanl {
00028 namespace Text {
00029
00030 using namespace Tanl::Text::Unicode;
00031
00032 int Char::ToDigit(int radix)
00033 {
00034 if (radix < MinRadix || radix > MaxRadix)
00035 return -1;
00036 if (ucs >= '0' && ucs <= '9')
00037 return ucs - '0';
00038 if (ucs >= 'A' && ucs <= 'Z' && ucs < radix + 'A' - 10)
00039 return ucs - 'A' + 10;
00040 if (ucs >= 'a' && ucs <= 'z' && ucs < radix + 'a' - 10)
00041 return ucs - 'a' + 10;
00042 return -1;
00043 }
00044
00045 Char Char::ToLower() const
00046 {
00047 int idx = UnicodeTable[ucs].downcase;
00048 if (idx == 0)
00049 return *this;
00050 return Char(idx);
00051 }
00052
00053 Char Char::ToUpper() const
00054 {
00055 int idx = UnicodeTable[ucs].upcase;
00056 if (idx == 0)
00057 return *this;
00058 return Char(idx);
00059 }
00060
00061 }
00062 }