flat assembler
Message board for the users of flat assembler.
Index
> Windows > String Coding problem |
Author |
|
kidscracker 19 Sep 2005, 20:35
Well as nobody answer my question I had to look for a solution. As i was thinking it was UTF8 encoded, so I had to look for the specification and make my own implementation, here is, I hope you will find it usefull,sorry if the comments are in Spanish .
Code: proc STR_UTF8ToUnicode,lptrUTF,lptrBuffer pushad mov esi,[lptrUTF] mov edi,[lptrBuffer] xor ebx,ebx ; DWORD que contendra el UNICODE xor ecx,ecx .ConvertLoop: lodsb ; Cargo Byte or cl,cl ; Contador de Bytes jz .NoReadingBytes ; Cero, No procesos UNICODE and al,3Fh ; Solo los 6 bits bajos shl ebx,6 ; Desplazo 6 bits or bl,al ; Combino dec cl ; Decremento Contador jnz .ConvertLoop ; !Cero, Siguiente Byte mov eax,ebx ; Valor UNICODE stosw ; Escribo xor ebx,ebx jmp .ConvertLoop ; Siguiente Byte .NoReadingBytes: or al,al ; NULL? jz .Done ; Termine test al,80h ; Bit 7 activo? jz .IsASCII ; No,Es ASCII mov ch,al ; Byte en CH shl ch,1 ; Elimino Bit 7 xor cl,cl ; Limpio CL(Contador de Bytes) .BytesCountLoop: shl ch,1 ; Roto jnc .ExitBytesCountLoop ; Era 0,Nada mas inc cl ; Incremento el contador jmp .BytesCountLoop ; Era 1,Pruebo Siguiente Bit .ExitBytesCountLoop: mov ah,07Fh ; Mascara de los 7 primeros bits shr ah,cl ; and al,ah ; Tomo los bits validos movzx ebx,al ; ECX contiene los bits altos jmp .ConvertLoop ; Siguiente Byte .IsASCII: xor ah,ah stosw ; Escribo el caracter(WORD) jmp .ConvertLoop .Done: xor eax,eax stosw popad ret endp |
|||
19 Sep 2005, 20:35 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.