Changeset 682 for trunk/ab5.0/ablib/src/Classes/System/Text
- Timestamp:
- Feb 16, 2009, 4:26:24 PM (15 years ago)
- Location:
- trunk/ab5.0/ablib/src/Classes/System/Text
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/ablib/src/Classes/System/Text/Encoding.ab
r676 r682 74 74 @date 2007/12/08 75 75 */ 76 Abstract Function GetBytesCountCore(src As *WCHAR, srcCount As Long) As Long 76 Virtual Function GetBytesCountCore(src As *WCHAR, srcCount As Long) As Long 77 Dim s = New IO.Detail.WriteCountingNullStream 78 GetEncoder().Encode(src, srcCount, s, True) 79 GetBytesCountCore = s.WriteCount 80 If GetBytesCountCore < 0 Then 81 Throw New OverflowException 82 End If 83 End Function 77 84 Public 78 85 /*! … … 110 117 @date 2007/12/08 111 118 */ 112 Abstract Function GetBytesCore(src As *WCHAR, srcCount As Long, dst As *Byte, dstCount As Long) As Long 119 Virtual Function GetBytesCore(src As *WCHAR, srcCount As Long, dst As *Byte, dstCount As Long) As Long 120 Dim s = New IO.MemoryStream 121 GetEncoder().Encode(src, srcCount, s, True) 122 Dim size = s.Position() 123 If size > (dstCount As QWord) Then 124 Throw New ArgumentException("dstCount") 125 End If 126 GetBytesCore = size As Long 127 memcpy(dst, s.ToPointer(), size As SIZE_T) 128 End Function 113 129 Public 114 130 /*! … … 136 152 @date 2007/12/08 137 153 */ 138 Abstract Function GetCharsCountCore(src As *Byte, srcCount As Long) As Long 154 Virtual Function GetCharsCountCore(src As *Byte, srcCount As Long) As Long 155 Dim s = New IO.MemoryStream(src, srcCount) 156 Dim l = New Collections.Generic.List<WCHAR> 157 GetDecoder().Decode(l, s) 158 GetCharsCountCore = l.Count 159 End Function 139 160 Public 140 161 /*! … … 172 193 @date 2007/12/08 173 194 */ 174 Abstract Function GetCharsCore(src As *Byte, srcCount As Long, dst As *WCHAR, dstCount As Long) As Long 195 Virtual Function GetCharsCore(src As *Byte, srcCount As Long, dst As *WCHAR, dstCount As Long) As Long 196 Dim s = New IO.MemoryStream(src, srcCount) 197 Dim l = New Collections.Generic.List<WCHAR> 198 GetDecoder().Decode(l, s) 199 If l.Count > dstCount Then 200 Throw New ArgumentException("dstCount") 201 End If 202 Dim p As *WCHAR 203 p = l 204 memcpy(dst, p, (l.Count As SIZE_T) * 2) 205 End Function 175 206 Public 176 207 #ifdef UNICODE -
trunk/ab5.0/ablib/src/Classes/System/Text/UTF8Encoding.ab
r676 r682 111 111 dst.Add((&hDC00 Or (buffer And &h3FF)) As WCHAR) 112 112 Else 113 '最短形式でないもの、 4バイト形式で10FFFFを超えるコードポイントのもの113 '最短形式でないもの、または4バイト形式で10FFFFを超えるコードポイントのもの 114 114 dst.Add(&hfffd As WCHAR) 115 115 End If … … 196 196 End Function 197 197 */ 198 Protected199 Override Function GetBytesCountCore(src As *WCHAR, srcCount As Long) As Long200 End Function201 202 Override Function GetBytesCore(src As *WCHAR, srcCount As Long, dst As *Byte, dstCount As Long) As Long203 End Function204 205 Override Function GetCharsCountCore(src As *Byte, srcCount As Long) As Long206 End Function207 208 Override Function GetCharsCore(src As *Byte, srcCount As Long, dst As *WCHAR, dstCount As Long) As Long209 End Function210 198 211 199 Private
Note:
See TracChangeset
for help on using the changeset viewer.