; -----------------------------------------------------------------------------
; Convert text to small/capital letter (invert)
; -----------------------------------------------------------------------------
; INPUT: AX = source code page
; BX = destination code page
; ECX = size of source buffer (bytes)
; EDX = invalid character (0 = use similar ASCII or default char)
; ESI = source buffer
; EDI = destination buffer (NULL = get required size of buffer)
; EBP = size of destination buffer (bytes, ignored if EDI=NULL)
; OUTPUT: EAX = size of destination data (bytes, 0=invalid code page)
; -----------------------------------------------------------------------------
; ------------- Push registers
CharTransSmaCap:push ebx ; push EBX
push ecx ; push ECX
push esi ; push ESI
push edi ; push EDI
push ebp ; push EBP
; ------------- Get source character set structure (-> EBX, later -> EAX)
push ebx ; push EBX (destination code page)
call GetCharSet ; get character set structure
pop eax ; EAX <- destination code page
jc CharTransSmaCa9 ; codepage not found
; ------------- Get destination character set structure (-> EBX)
push ebx ; push EBX (source character set)
call GetCharSet ; get character set structure
pop eax ; EAX <- source character set
jc CharTransSmaCa9 ; page not found
; ------------- Check destination buffer
or edi,edi ; is destination buffer valid?
jz CharTransSmaCa6 ; destination buffer is not valid
; ------------- Convert text
CharTransSmaCa4:jecxz CharTransSmaCa9 ; no source data
push eax ; push EAX (source character set)
push ebx ; push EBX (destination character set)
xchg eax,ebx ; EBX <- source character set
call dword [ebx+CHSET_ReadChar] ; read character
pop ebx ; pop EBX (destination character set)
call UniCharToSmaCap ; convert to small/capital letter
call dword [ebx+CHSET_WriteChar] ; write character
pop eax ; pop EAX (source character set
jmp short CharTransSmaCa4 ; next character
; ------------- Get size of buffer
CharTransSmaCa6:jecxz CharTransSmaCa9 ; no source data
push eax ; push EAX (source character set)
push ebx ; push EBX (destination character set)
xchg eax,ebx ; EBX <- source character set
call dword [ebx+CHSET_ReadChar] ; read character
pop ebx ; pop EBX (destination character set)
call UniCharToSmaCap ; convert to small/capital letter
call dword [ebx+CHSET_SizeChar] ; get size of character
pop eax ; pop EAX (source character set
jmp short CharTransSmaCa6 ; next character
; ------------- Pop registers
CharTransSmaCa9:xchg eax,edi ; EAX <- new destination bufferu
pop ebp ; pop EBP
pop edi ; pop EDI
pop esi ; pop ESI
pop ecx ; pop ECX
pop ebx ; pop EBX
sub eax,edi ; EAX <- size of data in buffer
ret
|