Changeset 143 for Include/Classes/System/String.ab
- Timestamp:
- Mar 10, 2007, 11:33:10 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/String.ab
r142 r143 565 565 End Function 566 566 567 Override Function GetHashCode() As Long 568 #ifdef __STRING_IS_NOT_UNICODE 569 Dim size = (m_Length + 1) >> 1 570 #else 571 Dim size = m_Length 572 #endif 573 Dim hash = 0 As DWord 574 Dim p = Chars As *Word 575 Dim i As Long 576 For i = 0 To ELM(size) 577 hash = ((hash << 16) + p[i]) Mod &h7fffffff 578 Next 579 Return hash As Long 580 End Function 567 581 Private 568 582 ' メモリ確保に失敗すると元の文字列は失われない。(例外安全でいう強い保障) … … 604 618 605 619 End Class 606 607 Function GetMultiByteStr(ByRef s As String) As PCSTR608 #ifdef __STRING_IS_NOT_UNICODE609 GetMultiByteStr = s.Chars610 #else611 Dim sizeA = WideCharToMultiByte(CP_THREAD_ACP, 0, s.Chars, s.Length + 1, 0, 0, 0, 0)612 GetMultiByteStr = GC_malloc_atomic(SizeOf (SByte) * sizeA)613 WideCharToMultiByte(CP_THREAD_ACP, 0, s.Chars, s.Length + 1, GetMultiByteStr, sizeA, 0, 0)614 #endif615 End Function616 617 Function GetWideCharStr(ByRef s As String) As PCSTR618 #ifdef __STRING_IS_NOT_UNICODE619 Dim sizeW = MultiByteToWideChar(CP_THREAD_ACP, 0, s.Chars, s.Length + 1, 0, 0)620 GetWideCharStr = GC_malloc_atomic(SizeOf (WCHAR) * sizeW)621 MultiByteToWideChar(CP_THREAD_ACP, 0, s.Chars, s.Length + 1, GetWideCharStr, sizeW)622 #else623 GetMultiByteStr = s.Chars624 #endif625 End Function626
Note:
See TracChangeset
for help on using the changeset viewer.