Changeset 655 for trunk/ab5.0/ablib/src/Classes/System/Text/Encoding.ab
- Timestamp:
- Nov 9, 2008, 2:21:49 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/ablib/src/Classes/System/Text/Encoding.ab
r653 r655 353 353 ByRef srcUsed As Long, ByRef dstUsed As Long, ByRef completed As Boolean) 354 354 355 If src = 0 Then355 If src = 0 And srcCount > 0 Then 356 356 Throw New ArgumentNullException("src") 357 357 ElseIf srcCount < 0 Then … … 452 452 ByRef srcUsed As Long, ByRef dstUsed As Long, ByRef completed As Boolean) 453 453 454 If src = 0 Then454 If src = 0 And srcCount > 0 Then 455 455 Throw New ArgumentNullException("src") 456 456 ElseIf srcCount < 0 Then … … 641 641 642 642 Override Function GetBytesCountCore(src As *WCHAR, srcCount As Long, flush As Boolean) As Long 643 GetBytesCountCore = srcCount * 2 + 1 '暫定 643 644 End Function 644 645 … … 658 659 Override Sub ConvertCore(src As *Byte, srcCount As Long, dst As *WCHAR, dstCount As Long, flush As Boolean, 659 660 ByRef srcUsed As Long, ByRef dstUsed As Long, ByRef completed As Boolean) 661 662 Dim srcPos = 0 As Long 663 Dim dstPos = 0 As Long 664 If dstCount > 0 And nextByte <> 0 Then 665 Dim buf[1] As CHAR 666 buf[0] = nextByte As CHAR 667 buf[1] = src[1] As CHAR 668 Dim len = MultiByteToWideChar(cp, 0, buf, Len(buf), VarPtr(dst[dstPos]), 10) 669 If len = 0 Then 670 ActiveBasic.Windows.ThrowWithLastError() 671 End If 672 srcPos++ 673 dstPos++ 674 nextByte = 0 675 End If 676 While srcPos < srcCount And dstPos < srcCount 677 Dim srcCharSize = 1 As Long 678 If IsDBCSLeadByteEx(cp, src[srcPos]) Then 679 srcCharSize = 2 680 If srcPos + 1 = srcCount Then 681 nextByte = src[srcPos] 682 Exit While 683 End If 684 End If 685 '将来的には行毎に変換しMB_USEGLYPHCHARSを使うようにしたい。 686 Dim len = MultiByteToWideChar(cp, 0, VarPtr(src[srcPos]) As *CHAR, srcCharSize, VarPtr(dst[dstPos]), 1) 687 If len = 0 Then 688 ActiveBasic.Windows.ThrowWithLastError() 689 End If 690 srcPos += srcCharSize 691 dstPos++ 692 Wend 693 srcUsed = srcPos 694 dstUsed = dstPos 695 completed = (srcPos = srcCount And dstPos = srcCount And nextByte = 0) 660 696 End Sub 661 697 662 698 Override Function GetCharsCountCore(src As *Byte, srcCount As Long, flush As Boolean) As Long 699 GetCharsCountCore = srcCount + 1 '暫定 663 700 End Function 664 701 665 702 Private 666 703 cp As DWord 704 nextByte As Byte 667 705 End Class 668 706
Note:
See TracChangeset
for help on using the changeset viewer.