News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Japanese text

Started by herge, September 18, 2008, 11:14:29 AM

Previous topic - Next topic

herge

 Hi ALL:

日本語の日時

This is date and time in Japanese!
I don't see it in qeditor. ie a bunch of ????
i do see.
I think I need unicows.dll and unicows.lib
Any help would be great.

Regards herge
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

Tedd

QEditor only supports ansi text, so you will get "?" for any characters not in the Latin-1 codepage.
"unicows" was a fix for non-NT versions to support unicode, you don't need it unless you're on Win95/98.

For Unicode text editing, you'll need an editor that supports it (notepad does :lol)
No snowflake in an avalanche feels responsible.

herge


Thanks Tedd:

I will have to do something else.

Regards herge
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

jj2007

herge,
Farabi asked for Arabic in this post. As it seems, Arabic can be displayed in RichMasm, which is based on RichEdit 3.0. I would be surprised if it didn't work for Japanese, but the language support must be enabled. Firefox does not ask for it, try MSIE instead. I just tried that on my puter, but it wants the original installation dvd, which is certainly lurking somewhere under a pile of .. somewhere in my office - if my vendor bothered to hand it out to me.

herge

 
Hi jj2007:

Yes it does display in Richmasm, but ML.EXE is going to
choke on it, IE give an error, in fact it does NOT like
unicode. ML.EXE can only handle ANSI text files.
I think I will have to create a text file in Notepad and
save as UNICODE and then read the file.
I must admit I have not tried this yet. Except that I
have created text files with  Japanese text with
Notepad.
You also have to set IE up for Japanese text.
I was going to use the adobe print pack
but does not work with adobe 9.0
I remember you needed a XP system disk at one point.

Regards herge
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

jj2007

Quote from: herge on September 21, 2008, 02:24:40 AM

Hi jj2007:

Yes it does display in Richmasm, but ML.EXE is going to
choke on it, IE give an error, in fact it does NOT like
unicode. ML.EXE can only handle ANSI text files.


Hmmmm.... RichMasm saves an Ansi text file (Tmp_file.asm) for assembly. ml.exe does not choke on a sample code with Arabic comments. I cannot test it for Japanese, though.

herge


Hi jj2007:


; JAPANESE.ASM 5:58:49 AM Thursday, September 18, 2008
include \masm32\include\masm32rt.inc
; Wednesday, July 16, 2008 9:17:12 AM
.data
dtbuf db 260 dup(0)
dw 0
AppName db "Date and Time", 0
crlf db 13, 10, 0
tf db "HH':'mm':'ss", 0
.code


Start:
invoke StdOut, addr AppName
invoke GetDateFormat, 1041, DATE_LONGDATE, 0, 0, addr dtbuf, 260
invoke lstrcat, addr dtbuf, addr crlf
push esi
mov esi, offset dtbuf
add esi, len(esi)
invoke GetTimeFormat, 1041, 0, 0, addr tf, esi, 40
pop esi
invoke MessageBoxW, NULL, addr dtbuf, addr AppName, MB_OK
         
        inkey
exit
      ret

end Start



This displays some Japanese script.
I have not a clue what it says.

Regards herge


[attachment deleted by admin]
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

six_L

try it.
invoke WideCharToMultiByte, CP_ACP, NULL, addr dtbuf, -1, addr buffer, 256, NULL, NULL
invoke MessageBoxW, NULL, addr buffer, addr AppName, MB_OK
regards

herge


hi six_L:

Did japanese.exe work?

Regards herge
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

six_L

i don't know.
i'm not a Japanese.
regards

jj2007

#10
Quote from: herge on September 21, 2008, 10:53:09 AM
Did japanese.exe work?

It can work only if Japanese language support is enabled.

EDIT: Here is a full example for various languages including Australian English :bg

; Date and time in any language to the clipboard - inspired by herge, 22.09.2008
; Country codes, see MSDN - last one in the list will be taken

CoCode = 0411h ; Japanese
CoCode = 03001h ; Arabic
CoCode = 0407h ; German
CoCode = 0c09h ; Australian English (greetings to Hutch)

.nolist
include \masm32\include\masm32rt.inc

Unicode2Clipboard PROTO: DWORD
szLenUC PROTO: DWORD

uchr$ MACRO ansitext:VARARG ; use like chr$, output is Unicode
LOCAL ansisrc, ucdest, strsize, quotes, srcarg
  quotes INSTR <ansitext>, <">
  if quotes eq 0
quotes INSTR <ansitext>, <'>
  endif
  if quotes
.data
ansisrc db ansitext, 0
strsize = SIZEOF ansisrc
srcarg equ <ansisrc>
  else
strsize = SIZEOF ansitext
srcarg equ <ansitext>
  endif
  .data?
ucdest dd strsize dup(?)
  .code
  mov eax, offset srcarg
  mov edx, offset ucdest
  call ansi2uc
  EXITM <offset ucdest>
ENDM

uclen MACRO lpString ; use like len, output is bytes (not words)
  invoke szLenUC, reparg(lpString)
  EXITM <eax>
ENDM;

.data?
dtbuf db 260 dup(?)
tmpbuffer dd 260 dup(?)

.data
crlf db 13, 10, 0

.code
Start: push esi
mov esi, offset dtbuf
invoke GetDateFormatW, CoCode, DATE_LONGDATE, 0, 0, esi, 520
invoke lstrcatW, addr dtbuf, uchr$(crlf)
invoke GetTimeFormatW, CoCode, 0, 0, uchr$("HH':'mm':'ss"), offset tmpbuffer, 40
invoke lstrcatW, addr dtbuf, offset tmpbuffer
invoke MessageBoxW, NULL, esi,
uchr$('Date and Time: Copy to clipboard?'),
MB_OKCANCEL or MB_DEFBUTTON2
.if eax==IDOK
invoke Unicode2Clipboard, esi
.endif
pop esi
exit

Unicode2Clipboard proc pBuffer
LOCAL cptClip:DWORD, hWnd
invoke GetDesktopWindow
mov hWnd, eax
push esi
push edi
push ebx
mov esi, pBuffer
mov ecx, uclen(esi)
add ecx, 2 ; len plus trailing nullword
push ecx
invoke GlobalAlloc, GHND or GMEM_SHARE, ecx
mov ebx, eax ; the handle
invoke GlobalLock, ebx ; returns dest pointer
mov edi, eax ; dest
pop ecx ; pushed len
sar ecx, 1 ; unicode, so let's
rep movsw ; move words
invoke GlobalUnlock, ebx
invoke OpenClipboard, hWnd
invoke EmptyClipboard
invoke SetClipboardData, CF_UNICODETEXT, ebx
invoke CloseClipboard
pop ebx
pop edi
pop esi
ret
Unicode2Clipboard endp

ansi2uc proc
  invoke MultiByteToWideChar,
CP_ACP, ; code page
MB_PRECOMPOSED, ; character-type options
eax, ; address of source string to map
-1, ; source string is zero delimited
edx, ; buffer that receives the translated string.
0FFFFFFFh ; size of buffer nearly unlimited
  ret
ansi2uc endp

szLenUC proc uses edi ecx src:DWORD
  or ecx, -1
  mov edi, src ; pointer to string
  xor eax, eax ; mov ax, 0
  repnz scasw ; rep until a nullword is found
  mov eax, ecx ; we take eax to preserve ecx
  not eax ; example 10 words: start -1,
  dec eax ; now -10: not -11 = 10
  add eax, eax ; we return bytes, not words
  ret
szLenUC endp

end Start

herge


Hi jj2007:

Great work.
It works for me!

Regards herge
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

herge


Hi jj2007:

A MicroSoft link for country locales.


http://www.microsoft.com/globaldev/reference/lcid-all.mspx


Regards herge
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

Mark Jones

Quote from: herge on September 21, 2008, 09:15:08 AM
...This displays some Japanese script. I have not a clue what it says...

Hello Herge, sorry I do not know what it says either. But it does display on my WinXP with the East-Asian language support installed. I just wanted to mention two things. First, several of the characters in that example did not display, and instead appeared as squares. Apparently some of those characters are not present on my system.

Second, I did a test of the number of clock cycles required to display ASCII text versus the same text as UNICODE, and despite the fact that modern Windows supposedly converts ASCII text to UNICODE internally to display it, there is virtually no speed improvement in using UNICODE strings natively.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

herge


Hi all:

This is a Date & Time Program.


; EFG.ASM Monday, September 22, 2008 6:47 AM
; Date & Time in English French German
; herge
include \masm32\include\masm32rt.inc
.data
dtbuf db 512 dup(0)
dd 0
index   dd 0
country dd 1036
dd 2060
dd 3084
dd 4108
dd 1043
dd 2067
dd 1126 ; Edo(45)
dd 1033
dd 2057
dd 3081
dd 10249
dd 4105 ; CANADA(50)
dd 9225
dd 15369
dd 16393
dd 14345
dd 6153
dd 8201
dd 17417
dd 5129
dd 13321
dd 18441
dd 7177
dd 11273
dd 1031
dd 3079
dd 5127
dd 4103
dd 2055
dd 1032
dd 1040
dd 2064
dd 1041

dd 0
location db "French - France",0
db "French - Belgium",0
db "French - Quebec",0
db "French - Swiss",0
db "Dutch - Netherlands",0
db "Dutch - Belgium",0
db "Edo",0  ; (45)
db "English - United States",0
db "English - United Kingdom",0
db "English - Australia",0
db "English - Belize",0
db "English - Canada",0
db "English - Caribbean",0
db "English - Hong Kong SAR",0
db "English - India",0
db "English - Indonesia",0
db "English - Ireland",0
db "English - Jamaica",0
db "English - Malaysia",0
db "English - New Zealand",0
db "English - Philippines",0
db "English - Singapore",0
db "English - South Africa",0
db "English - Trinidad",0
db "German - Germany",0
db "German - Austria",0
db "German - Liechtenstein",0
db "German - Luxembourg",0
db "German - Swiss",0
db "Greek",0
db "Italian - Italy",0
db "Italian - Swiss",0
db "Japanese",0
db 0

AppName db "Date and Time "
AppNameI db 20 dup(32)
db 0
Count db "Index Count "
CountI db 20 dup (32)
db 0
crlf db 13, 10, 0
dfo db "ddd',' MMM dd yyyy", 0 
tf db "hh':'mm':'ss tt", 0
.code
InsertEntry proc
; EDI > Out Print Buffer
; ECX = length
; ESI > In Table Buffer
      mov   ecx,0
@@:
mov al,[esi]
mov [edi],al
inc esi
inc edi
inc            ecx
and al,al
jnz @b
      mov   word ptr [edi-1], 0A0Dh
inc edi
inc ecx   
ret
InsertEntry endp
clearbuf proc
push ecx
mov ecx, 512
push edi
@@:
mov word ptr [edi], 0
add edi, 2
sub cx, 2
jc @F
jnz   @B
@@:; opps odd # or zero
pop edi
pop ecx
ret
clearbuf endp
PrintRegion proc
push ebx
push ecx
push esi
lea  esi, location
lea  edi, dtbuf
call clearbuf
call CX_TH_Entry
call InsertEntry
      lea  eax, dtbuf
      push edi
      sub  edi, eax
      mov  eax, edi
      pop  edi
pop  esi
      pop  ecx
pop  ebx
ret
PrintRegion endp
CX_TH proc
; ESI > Table
; ECX is entry in table we
; want.
; find cx_th entry in table
jcxz cx_th_exit
dec cx ; is it first entry
jcxz cx_th_exit; is first then exit
@@:
mov al,[esi] ; get a byte
inc esi ; point to next byte
and al,al ; is byte equal zero
jnz @B; search for zero
dec ecx
jnz @B; find cx_th zero
cx_th_exit:
; cx_th zero found exit
ret
CX_TH endp
CX_TH_Entry proc
push ecx
call CX_TH
pop ecx
ret
CX_TH_Entry endp
main proc
Start::
      mov   ecx, 0 
      lea   esi, country
@@:
      mov   ebx,[esi]
      and   ebx, ebx
      jz    @F
      inc   ecx
      mov   [index], ecx
      push  ecx
      push  esi
      call PrintRegion
      invoke GetDateFormat, ebx, 0, 0, addr dfo, edi, 260
      add   edi, eax
      mov   byte ptr [edi-1], " "    
      invoke GetTimeFormat, ebx, 0, 0, addr tf, edi, 40
      add   edi, eax
      mov   word ptr [edi-1], 0A0Dh
      inc   edi
      invoke dwtoa, index, addr AppNameI
      invoke dwtoa, index, edi ; convert prime to ASCII 
      invoke MessageBox, NULL, addr dtbuf, addr AppName, MB_OK
      pop   esi
      add   esi, 4
      pop   ecx
      jmp   @B
@@:
      invoke dwtoa, ecx, addr CountI; convert prime to ASCII
      invoke MessageBox, NULL, addr Count, addr Count, MB_OK
      invoke ExitProcess, NULL
      ret
main endp
end Start



Regards herge
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy