YSTest: chrmap.cpp 源文件

YSTest PreAlpha_b500_20140530 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
chrmap.cpp
浏览该文件的文档.
1 /*
2 © 2009-2013 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #include "CHRLib/YModules.h"
29 #include YFM_CHRLib_CharacterMapping
30
31 namespace CHRLib
32 {
33
34 using namespace CharSet;
35
36 size_t
37 FetchFixedCharWidth(Encoding cp)
38 {
39 switch(cp)
40 {
41 case csASCII:
42 return 1;
43 case csUnicode:
44 case csUTF16BE:
45 case csUTF16LE:
46 case csUTF16:
47 return 2;
48 case csUCS4:
49 case csUTF32:
50 case csUTF32BE:
51 case csUTF32LE:
52 return 4;
53 default:
54 return 0;
55 }
56 }
57
58 size_t
59 FetchMaxCharWidth(Encoding cp)
60 {
61 const auto r = FetchFixedCharWidth(cp);
62
63 return r == 0 ? FetchMaxVariantCharWidth(cp) : r;
64 }
65
66 size_t
67 FetchMaxVariantCharWidth(Encoding cp)
68 {
69 switch(cp)
70 {
71 case csGBK:
72 return 2;
73 case csGB18030:
74 case csUTF8:
75 return 4;
76 default:
77 return 0;
78 }
79 }
80
81 } // namespace CHRLib;
82
CHRLib::CharSet::csGBK
Definition: encoding.h:168
CHRLib::CharSet::csUTF32LE
Definition: encoding.h:193
CHRLib::CharSet::csGB18030
Definition: encoding.h:169
CHRLib::CharSet::csUnicode
Definition: encoding.h:175
CHRLib::CharSet::csUTF32
Definition: encoding.h:191
CHRLib::CharSet::csUTF32BE
Definition: encoding.h:192
CHRLib::FetchMaxVariantCharWidth
YF_API size_t FetchMaxVariantCharWidth(Encoding)
取指定变长编码的最大字符宽度。
Definition: chrmap.cpp:67
CHRLib::FetchFixedCharWidth
YF_API size_t FetchFixedCharWidth(Encoding)
取指定固定编码的固定字符宽度。
Definition: chrmap.cpp:37
CHRLib::CharSet::csUTF16BE
Definition: encoding.h:187
CHRLib::CharSet::csUTF16LE
Definition: encoding.h:188
CHRLib::CharSet::csASCII
Definition: encoding.h:60
CHRLib::FetchMaxCharWidth
YF_API size_t FetchMaxCharWidth(Encoding)
取指定编码的最大字符宽度。
Definition: chrmap.cpp:59
CHRLib::CharSet::csUTF8
Definition: encoding.h:163
YSLib::Drawing::r
bounds & r
Definition: ydraw.h:220
CHRLib::CharSet::Encoding
Encoding
Definition: encoding.h:53
CHRLib::CharSet::csUTF16
Definition: encoding.h:189
CHRLib::CharSet::csUCS4
Definition: encoding.h:176
YModules.h