Tvůrce webu je i pro tebe! Postav třeba web. Bez grafika. Bez kodéra. Hned.
wz

Obsah / Utility / CHARSET / CharTransSmaCap

Zdrojový kód: INCLUDE\UTIL\CHARSET.INC, UTIL\CHARSET.ASM


CharTransSmaCap - Konverze textu na malá/velká písmena

Funkce CharTransSmaCap zkonvertuje text na malá/velká písmena (tj. provede inverzi), případně též současně zkonvertuje text z jedné kódové stránky na jinou.


; -----------------------------------------------------------------------------
;                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

Funkce CharTransSmallCap je téměř shodná s funkcí CharTrans s tím rozdílem, že každý znak je po načtení zkonvertován na malé/velké písmeno funkcí UniCharToSmaCap.


Obsah / Utility / CHARSET / CharTransSmaCap