FineKernelToolKit 4.2.13
読み取り中…
検索中…
一致する文字列を見つけられません
UniCode.h
[詳解]
1#if !defined(__FK_UNICODE_HEADER__)
2#define __FK_UNICODE_HEADER__
3
4#include <vector>
5#include <FK/Base.h>
6
7namespace FK {
8
9 class fk_StrConverterBase;
10
12 enum class fk_StringCode {
13 UTF16,
14 UTF8,
15 JIS,
16 SJIS,
17 EUC
18 };
19
21
33 class fk_UniChar : public fk_BaseObject {
34 public:
36
42 fk_UniChar(int code = 0);
43
46
49
51
59 bool readFile(FILE *fp);
60
62
68 void setBuffer(unsigned char c1, unsigned char c2);
69
71
76 void setCode(int code);
77
79
84 int getCode(void);
85
87
93 bool isAscii(void);
94
96
104 char getAscii(void);
105
106 private:
107 int code;
108 };
109
111
125 class fk_UniStr : public fk_BaseObject {
126 public:
129
131 virtual ~fk_UniStr();
132
135
138
140
143 void clear(void);
144
146
152 int getLength(void) const;
153
155
176 bool getLine(fk_UniStr *str);
177
179
187 void markClear(void);
188
190
217
219
246 bool fgetLine(std::ifstream *ifs, fk_StringCode code = fk_StringCode::UTF16);
248
264 bool readFile(const std::string fileName,
266
268
276 void copyStr(fk_UniStr *str);
277
279
299 void convert(const std::string &str, fk_StringCode code);
300
302
325 void printf(fk_StringCode code, const char *format, ...);
326
328
337 int getCode(int num) const;
338
340
356 int find(int start, int code);
357
359
377 int find(int start, unsigned char c1, unsigned char c2);
378
380
383 void pop_back(void);
384
386
394
396
406
408
413 void push_back(int code);
414
415#if !defined(FK_DOXYGEN_USER_PROCESS)
416 void Print(std::string = "");
417#endif
418
419 private:
420 std::vector<int> uniStr;
421 int mark;
422
423 bool fgetLine_UTF16(FILE *);
424 bool fgetLine_UTF16(std::ifstream *);
425 };
426
428
451 public:
456
458
464 void convertJIS(const std::string &str, fk_UniStr *uniStr);
465
467
473 void convertSJIS(const std::string &str, fk_UniStr *uniStr);
474
476
482 void convertEUC(const std::string &str, fk_UniStr *uniStr);
483
485
491 void convertUTF8(const std::string &str, fk_UniStr *uniStr);
492
493
494
495#if !defined(FK_DOXYGEN_USER_PROCESS)
496 void convert_SJIS(const std::string &,
497 std::string *,
499
500 void convert_UTF8(const std::string &,
501 std::string *,
503#endif
504
505 private:
506 std::unique_ptr<fk_StrConverterBase> base;
507
508 void ConvertJIS_UTF8(const std::string &, std::string *);
509 void ConvertSJIS_UTF8(const std::string &, std::string *);
510 void ConvertEUC_UTF8(const std::string &, std::string *);
511 void ConvertUTF16_UTF8(const std::string &, std::string *);
512
513 void ConvertJIS_SJIS(const std::string &, std::string *);
514 void ConvertEUC_SJIS(const std::string &, std::string *);
515 void ConvertUTF8_SJIS(const std::string &, std::string *);
516 void ConvertUTF16_SJIS(const std::string &, std::string *);
517
518 };
519
521 namespace fk_Code {
522
524
530 void setInputCoding(fk_StringCode);
531
533
545 char * utf8(const std::string &str);
546
548
557 char * utf8(const std::string &str, fk_StringCode code);
558
560
572 char * sjis(const std::string &str);
573
575
584 char * sjis(const std::string &str, fk_StringCode code);
585 }
586}
587
588#endif // !__FK_UNICODE_HEADER__
589
590/****************************************************************************
591 *
592 * Copyright (c) 1999-2024, Fine Kernel Project, All rights reserved.
593 *
594 * Redistribution and use in source and binary forms,
595 * with or without modification, are permitted provided that the
596 * following conditions are met:
597 *
598 * - Redistributions of source code must retain the above
599 * copyright notice, this list of conditions and the
600 * following disclaimer.
601 *
602 * - Redistributions in binary form must reproduce the above
603 * copyright notice, this list of conditions and the
604 * following disclaimer in the documentation and/or
605 * other materials provided with the distribution.
606 *
607 * - Neither the name of the copyright holders nor the names
608 * of its contributors may be used to endorse or promote
609 * products derived from this software without specific
610 * prior written permission.
611 *
612 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
613 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
614 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
615 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
616 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
617 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
618 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
619 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
620 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
621 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
622 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
623 * POSSIBILITY OF SUCH DAMAGE.
624 *
625 ****************************************************************************/
626/****************************************************************************
627 *
628 * Copyright (c) 1999-2024, Fine Kernel Project, All rights reserved.
629 *
630 * 本ソフトウェアおよびソースコードのライセンスは、基本的に
631 * 「修正 BSD ライセンス」に従います。以下にその詳細を記します。
632 *
633 * ソースコード形式かバイナリ形式か、変更するかしないかを問わず、
634 * 以下の条件を満たす場合に限り、再頒布および使用が許可されます。
635 *
636 * - ソースコードを再頒布する場合、上記の著作権表示、本条件一覧、
637 * および下記免責条項を含めること。
638 *
639 * - バイナリ形式で再頒布する場合、頒布物に付属のドキュメント等の
640 * 資料に、上記の著作権表示、本条件一覧、および下記免責条項を
641 * 含めること。
642 *
643 * - 書面による特別の許可なしに、本ソフトウェアから派生した製品の
644 * 宣伝または販売促進に、本ソフトウェアの著作権者の名前または
645 * コントリビューターの名前を使用してはならない。
646 *
647 * 本ソフトウェアは、著作権者およびコントリビューターによって「現
648 * 状のまま」提供されており、明示黙示を問わず、商業的な使用可能性、
649 * および特定の目的に対する適合性に関す暗黙の保証も含め、またそれ
650 * に限定されない、いかなる保証もないものとします。著作権者もコン
651 * トリビューターも、事由のいかんを問わず、損害発生の原因いかんを
652 * 問わず、かつ責任の根拠が契約であるか厳格責任であるか(過失その
653 * 他の)不法行為であるかを問わず、仮にそのような損害が発生する可
654 * 能性を知らされていたとしても、本ソフトウェアの使用によって発生
655 * した(代替品または代用サービスの調達、使用の喪失、データの喪失、
656 * 利益の喪失、業務の中断も含め、またそれに限定されない)直接損害、
657 * 間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害に
658 * ついて、一切責任を負わないものとします。
659 *
660 ****************************************************************************/
FK の各クラスの基盤となる基本クラス
Definition Base.h:113
日本語文字コード変換クラス
Definition UniCode.h:450
void convertEUC(const std::string &str, fk_UniStr *uniStr)
EUCコード変換関数
fk_StrConverter(void)
コンストラクタ
virtual ~fk_StrConverter()
デストラクタ
void convertUTF8(const std::string &str, fk_UniStr *uniStr)
UTF-8 コード変換関数
void convertJIS(const std::string &str, fk_UniStr *uniStr)
JISコード変換関数
void convertSJIS(const std::string &str, fk_UniStr *uniStr)
Shift-JISコード変換関数
Unicode の文字を表すクラス
Definition UniCode.h:33
bool readFile(FILE *fp)
ファイル入力関数
int getCode(void)
文字コード参照関数
bool isAscii(void)
ASCII文字判定関数
fk_UniChar & operator=(const fk_UniChar &)
単純代入演算子
fk_UniChar(const fk_UniChar &)
コピーコンストラクタ
fk_UniChar(int code=0)
コンストラクタ
void setCode(int code)
文字コード設定関数2
char getAscii(void)
ASCII文字取得関数
void setBuffer(unsigned char c1, unsigned char c2)
文字コード設定関数1
文字列板に表示する文字列を制御するクラス
Definition UniCode.h:125
fk_UniStr(void)
コンストラクタ
fk_UniStr & operator=(const fk_UniStr &)
単純代入演算子
bool readFile(const std::string fileName, fk_StringCode code=fk_StringCode::UTF16)
ファイル全体取得関数
fk_UniStr(const fk_UniStr &)
コピーコンストラクタ
void markClear(void)
マーク初期化関数
void convert(const std::string &str, fk_StringCode code)
文字列生成関数
bool getLine(fk_UniStr *str)
一行分取得関数
int getLength(void) const
文字列長参照関数
int find(int start, int code)
文字検索関数1
void push_back(fk_UniChar c)
後部文字追加関数1
void push_back(fk_UniChar *c)
後部文字追加関数2
void clear(void)
初期化関数
void printf(fk_StringCode code, const char *format,...)
printf 形式書式付き文字列生成関数
bool fgetLine(std::ifstream *ifs, fk_StringCode code=fk_StringCode::UTF16)
ファイル一行分取得関数2
int find(int start, unsigned char c1, unsigned char c2)
文字検索関数2
int getCode(int num) const
文字コード参照関数
void pop_back(void)
最後尾文字削除関数
virtual ~fk_UniStr()
デストラクタ
void push_back(int code)
後部文字追加関数3
void copyStr(fk_UniStr *str)
文字列コピー関数
bool fgetLine(FILE *fp, fk_StringCode code=fk_StringCode::UTF16)
ファイル一行分取得関数1
Fine Kernel Toolkit 名前空間
Definition Angle.h:6
fk_StringCode
日本語文字コードを表す列挙型
Definition UniCode.h:12
@ JIS
ISO-2022-JIS (JISコード)
@ SJIS
Shift-JIS (SJISコード)
@ UTF8
Unicode (UTF-8)
@ UTF16
Unicode (UTF-16)
@ FILE
ファイル出力