; -----------------------------------------------------------------------------
; Convert text to capital letter
; -----------------------------------------------------------------------------
; 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
CharTransCap: 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 CharTransCap9 ; 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 CharTransCap9 ; page not found
; ------------- Check destination buffer
or edi,edi ; is destination buffer valid?
jz CharTransCap6 ; destination buffer is not valid
; ------------- Convert text
CharTransCap4: jecxz CharTransCap9 ; 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 UniCharToCap ; convert to capital letter
call dword [ebx+CHSET_WriteChar] ; write character
pop eax ; pop EAX (source character set
jmp short CharTransCap4 ; next character
; ------------- Get size of buffer
CharTransCap6: jecxz CharTransCap9 ; 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 UniCharToCap ; convert to capital letter
call dword [ebx+CHSET_SizeChar] ; get size of character
pop eax ; pop EAX (source character set
jmp short CharTransCap6 ; next character
; ------------- Pop registers
CharTransCap9: 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
|