Page 1 of 1

Problem to show language text

Posted: Tue Nov 09, 2004 10:46 pm
by LikePB
Hi to all PB users :D

I'm newbie user to join this nice forums.

I have a problem for show asian language in PB window.

I want show a arabic text in TextGadget , DrawText or another way to show an arabic text in my window. i use Ansi2Uni to convert text in unicode or use some arabic fonts but window can't show my text true.

How can i do this?

Posted: Tue Nov 09, 2004 10:56 pm
by GPI
maybe Shopro can help you with this problem.

(btw.: jaPBe should support asian language (you must set the codepage in the preferences)).

Posted: Wed Nov 10, 2004 1:57 am
by LikePB
GPI wrote: (btw.: jaPBe should support asian language (you must set the codepage in the preferences)).
Hi GPI

I use this too, i set codepage to Unicode UTF-8 and can write easy but when compile PB can's show that text true. now how must show this text in an window ? i think must use some API but not sure.

Posted: Wed Nov 10, 2004 10:13 pm
by LikePB
Don't know anybody ? :cry:

Posted: Thu Nov 11, 2004 10:38 am
by blueznl
haven't tried anything in this direction, but you got to remember a few things...

pb is ascii text, while windows is unicode text

all (string) functions in pb are non-unicode, and are zero terminated

as unicode contains loads of zeroes, you can imagine you have a little problem there

i am afraid that, for certain functions / gadgets / windows controls, you will have to do api calls to retrieve 'strange' characters from user input

but, perhaps i did not understand your question...

Posted: Thu Nov 11, 2004 12:28 pm
by El_Choni
I think yo must use CreateWindowExW_(). Try it first with the gadget, if it doesn't work, try the entire window.

Man, I'm helpy today, ain't I? :lol: I'll look for an example later, cya

Posted: Thu Nov 11, 2004 1:45 pm
by Num3
El_Choni wrote:I think yo must use CreateWindowExW_(). Try it first with the gadget, if it doesn't work, try the entire window.

Man, I'm helpy today, ain't I? :lol: I'll look for an example later, cya
Ehehehe... You're already working for next year paycheck raise... :mrgreen:

Posted: Thu Nov 11, 2004 2:55 pm
by El_Choni
Hi,

This works here (it's right aligned, since arabic is written right to left):

Code: Select all

Procedure a2u(text$)
  UniSize = (Len(text$)*2)+2
  *UniBuffer = AllocateMemory(UniSize+2)
  MultiByteToWideChar_(#CP_ACP, #NULL, text$, Len(text$), *UniBuffer, Len(text$))
  ProcedureReturn *UniBuffer
EndProcedure 

; Create some 'random' arabic Unicode chars

*ArabicText = AllocateMemory((($06D5-$060C)*2)+2)
*ArabicTextSeek.WORD = *ArabicText
For i=$060C To $06D5
  If (*ArabicTextSeek-*ArabicText)%11
    *ArabicTextSeek\w = i
  Else
    *ArabicTextSeek\w = ' ' ; some spaces to allow word wrapping
  EndIf
  *ArabicTextSeek+2
Next i
*ArabicTextSeek\w = 0

If OpenLibrary(0, "USER32.DLL")
  *CreateWindowExW = IsFunction(0, "CreateWindowExW")
  If *CreateWindowExW And OpenWindow(0, 0, 0, 400, 160,  #PB_Window_SystemMenu , "Show Unicode text")
    If CreateGadgetList(WindowID())
      hText = CallFunctionFast(*CreateWindowExW, 0, a2u("Static"), *ArabicText, #WS_VISIBLE|#WS_CHILD|#SS_RIGHT, 8, 8, 384, 144, WindowID(), 0, GetModuleHandle_(0), 0)
      If hText:SendMessage_(hText, #WM_SETFONT, GetStockObject_(#DEFAULT_GUI_FONT), 1):EndIf
      Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
    EndIf
  EndIf
  CloseLibrary(0)
EndIf
FreeMemory(*ArabicText)

Posted: Fri Nov 12, 2004 8:52 pm
by LikePB
blueznl thanks for your info.

El_Choni thank you so much :D

Its work peferct. but how can i just show my word on window ? i want cancel random mode and just show my word example: الحبيب

Thanks again.