UtfString.cpp

Go to the documentation of this file.
00001 
00012 #include "UtfString.h"
00013 
00014 
00015 size_t beego::ustrlen(const Uint16* str) {
00016 
00017   int length = 0;
00018   for (; str[length] != 0x0; ++length)
00019     ;
00020 
00021   return length;
00022 }
00023 
00024 
00025 int beego::ustrncmp(const Uint16* a, const Uint16* b, size_t n) {
00026   for (size_t i = 0; i < n; ++i) {
00027     int cmp = a[i] - b[i];
00028     if (cmp != 0) {
00029       return cmp;
00030     }
00031   }
00032   return 0;
00033 }
00034 
00035 
00036 void beego::ustrcat(std::vector<Uint16>& dest, const char* src) {
00037   if ((! dest.empty()) && (dest.back() == 0x0)) {
00038     dest.pop_back();
00039   }
00040 
00041   size_t n = strlen(src);
00042   for (size_t i = 0; i < n; ++i) {
00043     dest.push_back(src[i]);
00044   }
00045   dest.push_back(0x0);
00046 }
00047 
00048 
00049 void beego::ustrcat(std::vector<Uint16>& dest, const Uint16* src) {
00050   if ((! dest.empty()) && (dest.back() == 0x0)) {
00051     dest.pop_back();
00052   }
00053 
00054   // !!! ustrlen(const char*) になれば、ustrcat() の中身は、1つで済むのかな?
00055   size_t n = ustrlen(src);
00056   for (size_t i = 0; i < n; ++i) {
00057     dest.push_back(src[i]);
00058   }
00059   dest.push_back(0x0);
00060 }
00061 
00062 
00063 bool beego::isHiragana(const Uint16 wch) {
00064   if ((wch == 0) || (wch == 0x3090) || (wch == 0x3091) || (wch > 0x30f6)) {
00065     return false;
00066   } else {
00067     return true;
00068   }
00069 }
00070 
00071 
00072 void beego::uni2char(std::vector<char>& text, std::vector<Uint16>& utext) {
00073 
00074   for (std::vector<Uint16>::iterator it = utext.begin();
00075        it != utext.end(); ++it) {
00076     text.push_back(0xff & *it);
00077   }
00078 }
00079 

Generated on Mon Apr 13 22:52:01 2009 by  doxygen 1.5.7.1