Develop and Download Open Source Software

Browse Subversion Repository

Contents of /jpinput/UtfString.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 245 - (show annotations) (download) (as text)
Mon Feb 18 14:44:46 2008 UTC (16 years, 1 month ago) by satofumi
File MIME type: text/x-c++src
File size: 1471 byte(s)
now debugging rangesCtrl
1 /*!
2 \file
3 \brief UTF8 の文字列操作関数
4
5 \author Satofumi KAMIMURA
6
7 $Id$
8
9 \todo 関数の構成とオーバーロードのあたりを再検討する
10 */
11
12 #include "UtfString.h"
13
14
15 size_t beego::ustrlen(const Uint16* str) {
16
17 int length = 0;
18 for (; str[length] != 0x0; ++length)
19 ;
20
21 return length;
22 }
23
24
25 int beego::ustrncmp(const Uint16* a, const Uint16* b, size_t n) {
26 for (size_t i = 0; i < n; ++i) {
27 int cmp = a[i] - b[i];
28 if (cmp != 0) {
29 return cmp;
30 }
31 }
32 return 0;
33 }
34
35
36 void beego::ustrcat(std::vector<Uint16>& dest, const char* src) {
37 if ((! dest.empty()) && (dest.back() == 0x0)) {
38 dest.pop_back();
39 }
40
41 size_t n = strlen(src);
42 for (size_t i = 0; i < n; ++i) {
43 dest.push_back(src[i]);
44 }
45 dest.push_back(0x0);
46 }
47
48
49 void beego::ustrcat(std::vector<Uint16>& dest, const Uint16* src) {
50 if ((! dest.empty()) && (dest.back() == 0x0)) {
51 dest.pop_back();
52 }
53
54 // !!! ustrlen(const char*) になれば、ustrcat() の中身は、1つで済むのかな?
55 size_t n = ustrlen(src);
56 for (size_t i = 0; i < n; ++i) {
57 dest.push_back(src[i]);
58 }
59 dest.push_back(0x0);
60 }
61
62
63 bool beego::isHiragana(const Uint16 wch) {
64 if ((wch == 0) || (wch == 0x3090) || (wch == 0x3091) || (wch > 0x30f6)) {
65 return false;
66 } else {
67 return true;
68 }
69 }
70
71
72 void beego::uni2char(std::vector<char>& text, std::vector<Uint16>& utext) {
73
74 for (std::vector<Uint16>::iterator it = utext.begin();
75 it != utext.end(); ++it) {
76 text.push_back(0xff & *it);
77 }
78 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26