Problem to show language text

Just starting out? Need help? Post your questions and find answers here.
LikePB
New User
New User
Posts: 5
Joined: Tue Nov 09, 2004 10:14 pm

Problem to show language text

Post 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?
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

maybe Shopro can help you with this problem.

(btw.: jaPBe should support asian language (you must set the codepage in the preferences)).
LikePB
New User
New User
Posts: 5
Joined: Tue Nov 09, 2004 10:14 pm

Post 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.
LikePB
New User
New User
Posts: 5
Joined: Tue Nov 09, 2004 10:14 pm

Post by LikePB »

Don't know anybody ? :cry:
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post 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...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post 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
El_Choni
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post 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:
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post 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)
El_Choni
LikePB
New User
New User
Posts: 5
Joined: Tue Nov 09, 2004 10:14 pm

Post 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.
Post Reply