soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
strcpcvt.h
1#ifndef __STRCPCVT__H__
2#define __STRCPCVT__H__
3
4#include <windows.h>
5
6#ifndef CP_ACP
7#define CP_ACP 0
8#endif // CP_ACP
9
10#include "utilities-def.h"
11#include "tstring.h"
12
13SNSBEGIN
14
15/**
16 * @class SStrCpCvt
17 * @brief Class for string code page conversion.
18 * @details Provides static methods to convert strings between different code pages.
19 */
20class UTILITIES_API SStrCpCvt
21{
22public:
23 /**
24 * @brief Converts a wide string (UTF-16) to a multi-byte string (ANSI or specified code page).
25 * @param str Wide string to convert.
26 * @param cp Code page for the output multi-byte string (default is CP_ACP).
27 * @return Converted multi-byte string.
28 */
29 static SStringA CvtW2A(const SStringW &str, unsigned int cp = CP_ACP);
30
31 /**
32 * @brief Converts a multi-byte string (ANSI or specified code page) to a wide string (UTF-16).
33 * @param str Multi-byte string to convert.
34 * @param cp Code page of the input multi-byte string (default is CP_ACP).
35 * @param cp2 Reserved parameter (default is 0).
36 * @return Converted wide string.
37 */
38 static SStringW CvtA2W(const SStringA &str, unsigned int cp = CP_ACP, unsigned int cp2 = 0);
39
40 /**
41 * @brief Converts a multi-byte string from one code page to another multi-byte code page.
42 * @param str Multi-byte string to convert.
43 * @param cpFrom Source code page (default is CP_UTF8).
44 * @param cpTo Target code page (default is CP_ACP).
45 * @return Converted multi-byte string.
46 */
47 static SStringA CvtA2A(const SStringA &str, unsigned int cpFrom = CP_UTF8, unsigned int cpTo = CP_ACP);
48
49 /**
50 * @brief Converts a wide string (UTF-16) to another wide string (UTF-16) with a specified code page.
51 * @param str Wide string to convert.
52 * @param cp Code page for the output wide string (default is CP_ACP).
53 * @return Converted wide string.
54 */
55 static SStringW CvtW2W(const SStringW &str, unsigned int cp = CP_ACP);
56};
57
58SNSEND
59
60/**
61 * @brief Macro for converting a multi-byte string to a wide string.
62 * @param str Multi-byte string to convert.
63 * @param cp Code page of the input multi-byte string (default is CP_ACP).
64 * @param cp2 Reserved parameter (default is 0).
65 * @return Converted wide string.
66 */
67#define S_CA2W SStrCpCvt::CvtA2W
68
69/**
70 * @brief Macro for converting a wide string to a multi-byte string.
71 * @param str Wide string to convert.
72 * @param cp Code page for the output multi-byte string (default is CP_ACP).
73 * @return Converted multi-byte string.
74 */
75#define S_CW2A SStrCpCvt::CvtW2A
76
77/**
78 * @brief Macro for converting a multi-byte string from one code page to another multi-byte code page.
79 * @param str Multi-byte string to convert.
80 * @param cpFrom Source code page (default is CP_UTF8).
81 * @param cpTo Target code page (default is CP_ACP).
82 * @return Converted multi-byte string.
83 */
84#define S_CA2A SStrCpCvt::CvtA2A
85
86/**
87 * @brief Macro for converting a wide string to another wide string with a specified code page.
88 * @param str Wide string to convert.
89 * @param cp Code page for the output wide string (default is CP_ACP).
90 * @return Converted wide string.
91 */
92#define S_CW2W SStrCpCvt::CvtW2W
93
94#ifdef UNICODE
95/**
96 * @brief Macro for converting a multi-byte string to a wide string (Unicode version).
97 * @param str Multi-byte string to convert.
98 * @param cp Code page of the input multi-byte string (default is CP_ACP).
99 * @param cp2 Reserved parameter (default is 0).
100 * @return Converted wide string.
101 */
102#define S_CA2T S_CA2W
103
104/**
105 * @brief Macro for converting a wide string to a multi-byte string (Unicode version).
106 * @param str Wide string to convert.
107 * @param cp Code page for the output multi-byte string (default is CP_ACP).
108 * @return Converted multi-byte string.
109 */
110#define S_CT2A S_CW2A
111
112/**
113 * @brief Macro for converting a wide string to another wide string with a specified code page (Unicode version).
114 * @param str Wide string to convert.
115 * @param cp Code page for the output wide string (default is CP_ACP).
116 * @return Converted wide string.
117 */
118#define S_CW2T S_CW2W
119
120/**
121 * @brief Macro for converting a wide string to another wide string with a specified code page (Unicode version).
122 * @param str Wide string to convert.
123 * @param cp Code page for the output wide string (default is CP_ACP).
124 * @return Converted wide string.
125 */
126#define S_CT2W S_CW2W
127#else
128/**
129 * @brief Macro for converting a multi-byte string to a wide string (ANSI version).
130 * @param str Multi-byte string to convert.
131 * @param cp Code page of the input multi-byte string (default is CP_ACP).
132 * @param cp2 Reserved parameter (default is 0).
133 * @return Converted wide string.
134 */
135#define S_CA2T S_CA2A
136
137/**
138 * @brief Macro for converting a wide string to a multi-byte string (ANSI version).
139 * @param str Wide string to convert.
140 * @param cp Code page for the output multi-byte string (default is CP_ACP).
141 * @return Converted multi-byte string.
142 */
143#define S_CT2A S_CA2A
144
145/**
146 * @brief Macro for converting a wide string to another wide string with a specified code page (ANSI version).
147 * @param str Wide string to convert.
148 * @param cp Code page for the output wide string (default is CP_ACP).
149 * @return Converted wide string.
150 */
151#define S_CW2T S_CW2A
152
153/**
154 * @brief Macro for converting a wide string to another wide string with a specified code page (ANSI version).
155 * @param str Wide string to convert.
156 * @param cp Code page for the output wide string (default is CP_ACP).
157 * @return Converted wide string.
158 */
159#define S_CT2W S_CA2W
160#endif // UNICODE
161
162#endif // __STRCPCVT__H__
Class for string code page conversion.
Definition strcpcvt.h:21
static SStringA CvtA2A(const SStringA &str, unsigned int cpFrom=CP_UTF8, unsigned int cpTo=0)
Converts a multi-byte string from one code page to another multi-byte code page.
Definition strcpcvt.cpp:10
static SStringA CvtW2A(const SStringW &str, unsigned int cp=0)
Converts a wide string (UTF-16) to a multi-byte string (ANSI or specified code page).
Definition strcpcvt.cpp:42
static SStringW CvtA2W(const SStringA &str, unsigned int cp=0, unsigned int cp2=0)
Converts a multi-byte string (ANSI or specified code page) to a wide string (UTF-16).
Definition strcpcvt.cpp:18
static SStringW CvtW2W(const SStringW &str, unsigned int cp=0)
Converts a wide string (UTF-16) to another wide string (UTF-16) with a specified code page.
Definition strcpcvt.cpp:5
A class representing an ASCII string.
Definition sstringa.h:96
A class representing an ASCII string.
Definition sstringw.h:96