Code : Tout sélectionner
Procedure.l Ansi2Uni(ansi.s)
size.l=MultiByteToWideChar_(#CP_ACP,0,ansi,-1,0,0)
Dim unicode.w(size)
MultiByteToWideChar_(#CP_ACP, 0, ansi, Len(ansi), unicode(), size)
ProcedureReturn @unicode()
EndProcedure
Procedure.s Uni2Ansi(*Unicode.l)
size.l = WideCharToMultiByte_(#CP_ACP, 0, *Unicode, -1, #Null, #Null, #Null, #Null)
ansi.s=Space(size)
WideCharToMultiByte_(#CP_ACP, 0, *Unicode, -1, @ansi, size, #Null, #Null)
ProcedureReturn ansi
EndProcedure
*pointeur=Ansi2Uni("Ben ça alors, dis donc, si j'avais su.")
Debug Uni2Ansi(*pointeur)
Un exemple:
Code : Tout sélectionner
Procedure.l Ansi2Uni(ansi.s)
size.l=MultiByteToWideChar_(#CP_ACP,0,ansi,-1,0,0)
Dim unicode.w(size)
MultiByteToWideChar_(#CP_ACP, 0, ansi, Len(ansi), unicode(), size)
ProcedureReturn @unicode()
EndProcedure
If OpenWindow(0, 200, 200, 400, 100, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "PureBasic Window")
CreateGadgetList(WindowID(0))
ButtonGadget(0, 320, 20, 60, 20, "Go")
StringGadget(1,10,20,300,20,"Borderless StringGadget",#PB_String_BorderLess)
EndIf
SetGadgetText(1, "http://www.purebasic.com/screenshots/Editor.png")
Repeat
event = WindowEvent()
Select event
Case #PB_EventGadget
Select EventGadgetID()
Case 0
If OpenLibrary(0,"shdocvw.dll") And IsFunction(0,"DoFileDownload")
texte$=GetGadgetText(1)
CallFunction(0,"DoFileDownload",Ansi2Uni(texte$))
EndIf
EndSelect
EndSelect
Until event =#PB_EventCloseWindow
CloseLibrary(0)
End
