- Timestamp:
- Nov 3, 2008, 10:23:32 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/ablib/src/system/string.sbp
r497 r652 28 28 Function GetWCStr(mbsSrc As PSTR, len As SIZE_T, ByRef wcsDst As PWSTR) As SIZE_T 29 29 Dim lenWCS = MultiByteToWideChar(CP_THREAD_ACP, 0, mbsSrc, (len As DWord) As Long, 0, 0) 30 wcsDst = _System_AllocForConvertedString(SizeOf (WCHAR) * (lenWCS + 1)) As PWSTR30 wcsDst = _System_AllocForConvertedString(SizeOf (WCHAR) * lenWCS) As PWSTR 31 31 GetWCStr = MultiByteToWideChar(CP_THREAD_ACP, 0, mbsSrc, (len As DWord) As Long, wcsDst, lenWCS) 32 wcsDst[GetWCStr] = 033 32 End Function 34 33 … … 40 39 Function GetMBStr(wcsSrc As PWSTR, len As SIZE_T, ByRef mbsDst As PSTR) As SIZE_T 41 40 Dim lenMBS = WideCharToMultiByte(CP_THREAD_ACP, 0, wcsSrc, (len As DWord) As Long, 0, 0, 0, 0) 42 mbsDst = _System_AllocForConvertedString(SizeOf ( SByte) * (lenMBS + 1)) As PSTR41 mbsDst = _System_AllocForConvertedString(SizeOf (CHAR) * lenMBS) As PSTR 43 42 GetMBStr = WideCharToMultiByte(CP_THREAD_ACP, 0, wcsSrc, (wcsSrc As DWord) As Long, mbsDst, lenMBS, 0, 0) As SIZE_T 44 mbsDst[GetMBStr] = 045 43 End Function 46 44 … … 49 47 GetMBStr = len 50 48 End Function 49 50 ' ToTCStrの補助 51 Sub GetStrNT(mbszSrc As PSTR, ByRef mbszDst As PSTR) 52 mbszDst = mbszSrc 53 End Sub 54 55 Sub GetStrNT(mbszSrc As PSTR, ByRef wcszDst As PWSTR) 56 GetStr(mbszSrc, wcszDst) 57 End Sub 58 59 Sub GetStrNT(wcszSrc As PWSTR, ByRef mbszDst As PSTR) 60 GetStr(wcszSrc, mbszDst) 61 End Sub 62 63 Sub GetStrNT(wcszSrc As PWSTR, ByRef wcszDst As PWSTR) 64 wcszDst = wcszSrc 65 End Sub 66 51 67 End Namespace 52 68 … … 55 71 入力引数: wcsz, wcs + len, mbsz, mbs + len, str 56 72 出力関数: wcs(z)出力GetStr, mbs(z)出力GetStr, 57 wcs(z)出力GetStrNT, mbs(z)出力GetStrNT,58 73 GetWCStr, GetMBStr, GetTCStr, 59 74 ToWCStr, ToMBStr, ToTCStr, 60 で、5 * 10 = 50通り。75 で、5 * 8 = 40通り。 61 76 */ 62 77 … … 66 81 Return 0 67 82 Else 68 Return Detail.GetWCStr(mbszSrc, lstrlenA(mbszSrc) As SIZE_T, wcsDst)83 Return Detail.GetWCStr(mbszSrc, (lstrlenA(mbszSrc) + 1) As SIZE_T, wcsDst) 69 84 End If 70 85 End Function … … 85 100 Else 86 101 wcsDst = wcszSrc 87 Return lstrlenW(wcszSrc) As SIZE_T 102 Return lstrlenW(wcszSrc) As SIZE_T + 1 88 103 End If 89 104 End Function … … 104 119 Return 0 105 120 Else 106 Return Detail.GetMBStr(wcszSrc, lstrlenW(wcszSrc) As SIZE_T, mbsDst)121 Return Detail.GetMBStr(wcszSrc, (lstrlenW(wcszSrc) + 1) As SIZE_T, mbsDst) 107 122 End If 108 123 End Function … … 123 138 Else 124 139 mbsDst = mbszSrc 125 Return lstrlenA(mbszSrc) As SIZE_T 140 Return lstrlenA(mbszSrc) As SIZE_T + 1 126 141 End If 127 142 End Function … … 155 170 End Function 156 171 157 Sub GetStrNT(mbszSrc As PSTR, ByRef mbszDst As PSTR)158 mbszDst = mbszSrc159 End Sub160 161 Sub GetStrNT(mbsSrc As PSTR, len As SIZE_T, ByRef mbszDst As PSTR)162 mbszDst = mbsSrc163 End Sub164 165 Sub GetStrNT(mbszSrc As PSTR, ByRef wcszDst As PWSTR)166 GetStr(mbszSrc, wcszDst)167 End Sub168 169 Sub GetStrNT(mbsSrc As PSTR, len As SIZE_T, ByRef wcszDst As PWSTR)170 GetStr(mbsSrc, len, wcszDst)171 End Sub172 173 Sub GetStrNT(wcszSrc As PWSTR, ByRef mbszDst As PSTR)174 GetStr(wcszSrc, mbszDst)175 End Sub176 177 Sub GetStrNT(wcsSrc As PWSTR, len As SIZE_T, ByRef mbszDst As PSTR)178 GetStr(wcsSrc, len, mbszDst)179 End Sub180 181 Sub GetStrNT(wcszSrc As PWSTR, ByRef wcszDst As PWSTR)182 wcszDst = wcszSrc183 End Sub184 185 Sub GetStrNT(wcsSrc As PWSTR, len As SIZE_T, ByRef wcszDst As PWSTR)186 wcszDst = wcsSrc187 End Sub188 189 Sub GetStrNT(strSrc As String, ByRef mbszDst As PSTR)190 GetStr(strSrc, mbszDst)191 End Sub192 193 Sub GetStrNT(strSrc As String, ByRef wcszDst As PWSTR)194 GetStr(strSrc, wcszDst)195 End Sub196 197 172 Function GetWCStr(mbszSrc As PSTR, ByRef wcsDst As PWSTR) As SIZE_T 198 173 Return GetStr(mbszSrc, wcsDst) … … 256 231 257 232 Function ToWCStr(mbsz As PSTR) As PWSTR 258 GetStrNT(mbsz, ToWCStr)233 Detail.GetStrNT(mbsz, ToWCStr) 259 234 End Function 260 235 261 236 Function ToWCStr(mbs As PSTR, len As SIZE_T) As PWSTR 262 GetStr NT(mbs, len, ToWCStr)237 GetStr(mbs, len, ToWCStr) 263 238 End Function 264 239 … … 272 247 273 248 Function ToWCStr(s As String) As PWSTR 274 GetStr NT(s, ToWCStr)249 GetStr(s, ToWCStr) 275 250 End Function 276 251 … … 284 259 285 260 Function ToMBStr(wcsz As PWSTR) As PSTR 286 GetStrNT(wcsz, ToMBStr)261 Detail.GetStrNT(wcsz, ToMBStr) 287 262 End Function 288 263 289 264 Function ToMBStr(wcs As PWSTR, len As SIZE_T) As PSTR 290 GetStr NT(wcs, len, ToMBStr)265 GetStr(wcs, len, ToMBStr) 291 266 End Function 292 267 293 268 Function ToMBStr(s As String) As PSTR 294 GetStr NT(s, ToMBStr)269 GetStr(s, ToMBStr) 295 270 End Function 296 271 297 272 Function ToTCStr(mbsz As PSTR) As PCTSTR 298 GetStrNT(mbsz, ToTCStr)273 Detail.GetStrNT(mbsz, ToTCStr) 299 274 End Function 300 275 301 276 Function ToTCStr(mbs As PSTR, len As SIZE_T) As PCTSTR 302 GetStr NT(mbs, len, ToTCStr)277 GetStr(mbs, len, ToTCStr) 303 278 End Function 304 279 305 280 Function ToTCStr(wcsz As PWSTR) As PCTSTR 306 GetStrNT(wcsz, ToTCStr)281 Detail.GetStrNT(wcsz, ToTCStr) 307 282 End Function 308 283 309 284 Function ToTCStr(wcs As PWSTR, len As SIZE_T) As PCTSTR 310 GetStr NT(wcs, len, ToTCStr)285 GetStr(wcs, len, ToTCStr) 311 286 End Function 312 287 313 288 Function ToTCStr(s As String) As PCTSTR 314 GetStrNT(s, ToTCStr)289 Return StrPtr(s) 315 290 End Function 316 291
Note:
See TracChangeset
for help on using the changeset viewer.