Changeset 394 for trunk/Include/basic/function.sbp
- Timestamp:
- Dec 9, 2007, 3:03:51 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/basic/function.sbp
r388 r394 243 243 '------------ 244 244 245 Function Asc(buf As *StrChar) As StrChar245 Function Asc(buf As String) As StrChar 246 246 Asc = buf[0] 247 247 End Function … … 253 253 #ifndef __STRING_IS_NOT_UNICODE 254 254 Function AscW(s As String) As UCSCHAR 255 If s.Length = 0Then255 If String.IsNullOrEmpty(s) Then 256 256 AscW = 0 257 Else 258 If _System_IsSurrogatePair(s[0], s[1]) Then 259 AscW = ((s[0] And &h3FF) As DWord << 10) Or (s[1] And &h3FF) 257 'ArgumentNullExceptionに変えるかも 258 Else 259 If _System_IsHighSurrogate(s[0]) Then 260 '有効なサロゲートペアになっていない場合には、 261 '例外を投げるようにしたほうがよいかもしれない。 262 If s.Length > 1 Then 263 If _System_IsLowSurrogate(s[0]) Then 264 AscW = ((s[0] And &h3FF) As DWord << 10) Or (s[1] And &h3FF) 265 Exit Function 266 End If 267 End If 260 268 Else 261 269 AscW = s[0] … … 267 275 If c <= &hFFFF Then 268 276 Return New String(c As StrChar, 1) 269 ElseIf c < &h10FFFF Then 270 Dim t[1] = [&hD800 Or (c >> 10), &hDC00 Or (c And &h3FF)] As WCHAR 277 ElseIf c <= &h10FFFF Then 278 Dim t[1] As WCHAR 279 t[0] = (&hD800 Or (c >> 10)) As WCHAR 280 t[1] = (&hDC00 Or (c And &h3FF)) As WCHAR 271 281 Return New String(t, 2) 272 282 Else 273 'ArgumentOutOfRangeException283 Throw New System.ArgumentOutOfRangeException("ChrW: c is invalid Unicode code point.", "c") 274 284 End If 275 285 End Function … … 691 701 Else 692 702 '10進数 703 #ifdef __STRING_IS_NOT_UNICODE 693 704 sscanf(buf,"%lf",VarPtr(Val)) 705 #else 706 swscanf(buf,ToWCStr("%lf"),VarPtr(Val)) 707 #endif 694 708 End If 695 709 End Function … … 917 931 End Function 918 932 933 Function _System_HashFromUInt(x As QWord) As Long 934 Return (HIDWORD(x) Xor LODWORD(x)) As Long 935 End Function 936 937 Function _System_HashFromUInt(x As DWord) As Long 938 Return x As Long 939 End Function 940 919 941 Function _System_HashFromPtr(p As VoidPtr) As Long 920 #ifdef _WIN64 921 Dim qw = p As QWord 922 Return (HIDWORD(qw) Xor LODWORD(qw)) As Long 923 #else 924 Return p As Long 925 #endif 942 Return _System_HashFromUInt(p As ULONG_PTR) 926 943 End Function 927 944 … … 952 969 '-------- 953 970 Function _System_IsSurrogatePair(wcHigh As WCHAR, wcLow As WCHAR) As Boolean 954 If &hD800 <= wcHigh And wcHigh < &hDC00Then955 If &hDC00 <= wcLow And wcLow < &hE000Then971 If _System_IsHighSurrogate(wcHigh) Then 972 If _System_IsLowSurrogate(wcLow) Then 956 973 Return True 957 974 End If 958 975 End If 959 976 Return False 977 End Function 978 979 Function _System_IsHighSurrogate(c As WCHAR) As Boolean 980 Return &hD800 <= c And c < &hDC00 981 End Function 982 983 Function _System_IsLowSurrogate(c As WCHAR) As Boolean 984 Return &hDC00 <= c And c < &hE000 960 985 End Function 961 986
Note:
See TracChangeset
for help on using the changeset viewer.