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

Obsah / Utility / CHARSET / CharUTF16BEW

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


CharUTF16BEW - Uložení znaku do bufferu ve formátu UTF-16BE

Funkce CharUTF16BEW uloží Unicode znak do bufferu v kódu UTF-16BE, big endian (tj. formát Macintosh, v paměti je uložen nejdříve vyšší bajt dat a poté nižší bajt).


; -----------------------------------------------------------------------------
;            Write character into UTF-16BE (MAC, big endian) buffer
; -----------------------------------------------------------------------------
; INPUT:	EAX = Unicode character
;		EDI = destination buffer
;		EBP = remaining space in buffer
; OUTPUT:	EDI = next destination buffer
;		EBP = next remaining space in buffer
; DESTROYS:	EAX
; -----------------------------------------------------------------------------

; ------------- 1 Word (almost 16 bits, 0000..D7FF or E000..FFFF)

CharUTF16BEW:	or	ebp,ebp		; check free space
		jz	CharUTF16BEW7	; buffer full
                                    
		cmp	eax,0ffffh	; 1 word?
		ja	CharUTF16BEW6	; more than 1 word

		xchg	al,ah		; exchange byte order
		dec	ebp		; decrease remaining space
		jz	CharUTF16LEW3	; buffer full
		dec	ebp		; decrease remaining space
		stosw			; store character
		ret

; ------------- 2 Words (20 bits, 110110xxxxxxxxxx 110111xxxxxxxxxx 
;				= D800..DBFF DC00..DFFF)
CharUTF16BEW6:	push	eax		; push EAX
		shr	eax,10		; EAX <- high 10 bits
		add	eax,0d800h-40h	; add high surrogate start - base
		xchg	al,ah		; exchange byte order
		dec	ebp		; decrease remaining space
		jz	CharUTF16LEW8	; buffer full
		stosw			; store high word
		pop	eax		; pop EAX

		dec	ebp		; decrease remaining space
		jz	CharUTF16BEW7	; buffer full

		and	eax,3ffh	; mask low 10 bits
		add	eax,0dc00h	; add low surrogate start
		xchg	al,ah		; exchange byte order
                dec	ebp		; decrease remaining space
		jz	CharUTF16LEW3	; buffer full
		dec	ebp		; decrease remaining space
		stosw			; store low word
CharUTF16BEW7:	ret

Funkce je téměř shodná s funkcí CharUTF16LEW s tím rozdílem, že je zaměněno pořadí bajtů ukládaných slov.


Obsah / Utility / CHARSET / CharUTF16BEW