L'unicode nous surprend tous un peu. Les milliers de caractères possible
Comme par exemple l'euro que l'on ne trouve plus ect.
Donc j'ai réalisé ce petit outil sans prétention, mais qui me rend bien des services.
L'utilisation est simple:
Tapez un code en décimale ou en hexa et le caractère s'affiche.
Autre possiblité aprés avoir coché recherche par caractère. Taper un caractère ou copier le contenus du P.P dans la bonne case et le code
s'affiche.
si vous ête en reche par numéro, et que vous appuyez sur le bouton copie le caractère sera dans le P.P, en recherche par caractère
se sera le code héxa.
Bien entendus, vous pouvez amélioré la bête. Mais faite nous une démo.
Code : Tout sélectionner
; Code-Unicode By MLD le 19/09/2016
;PB 5.43LTS. Compilation uni_code
Enumeration
#Ma_fen = 0
#txt_1 = 1
#string_1 = 2
#string_2 = 3
#string_3 = 4
#bt_p = 5
#bt_m = 6
#CheckBox_num = 7
#CheckBox_car = 8
#Bt_copie = 9
#Bt_Raz = 10
#Bt_stop = 11
#Etic_1 = 12
#Etic_2 = 13
#Etic_3 = 14
EndEnumeration
Declare afcarac(nc)
Global FontID1 = LoadFont(30,"Tahoma",12,#PB_Font_Bold)
Global FontID2 = LoadFont(31,"Tahoma",36,#PB_Font_HighQuality)
Global FontID3 = LoadFont(32,"Tahoma",12,#PB_Font_HighQuality)
Global A$="NUL;SOH;STX;ETX;EOT;ENQ;ACK;BEL;BS;HT;LF;VT;FF;CR;SO;SI;DLE;DC1;DC2;DC3;DC4;NAK;SYN;ETB;CAN;EM;SUB;ESC;FS;GS;RS;US;SP;"
Macro Select(num)
If num = 1 Or num = 3
SetGadgetColor(2,#PB_Gadget_BackColor,$FFFFFF)
SetGadgetColor(3,#PB_Gadget_BackColor,$2FFFAD)
SetGadgetColor(4,#PB_Gadget_BackColor,$2FFFAD)
DisableGadget(2,1):DisableGadget(3,0):DisableGadget(4,0)
DisableGadget(5,0):DisableGadget(6,0)
If num = 3
SetGadgetText(2,"NUL")
SetGadgetText(3,"0")
SetGadgetText(4,"00")
EndIf
Else
SetGadgetColor(2,#PB_Gadget_BackColor,$2FFFAD)
SetGadgetColor(3,#PB_Gadget_BackColor,$FFFFFF)
SetGadgetColor(4,#PB_Gadget_BackColor,$FFFFFF)
For x = 2 To 4
SetGadgetText(x,"")
Next
DisableGadget(2,0):DisableGadget(3,1):DisableGadget(4,1)
DisableGadget(5,1):DisableGadget(6,1)
EndIf
EndMacro
Procedure GestionCaret(Gadget) ; Gestion du caret dans stringGadget
SendMessage_(GadgetID(Gadget), #EM_GETSEL, @Debut_Position, @Fin_position)
y = Debut_Position
Texte.s = GetGadgetText(Gadget)
x =Len(Texte)
Texte2.s = Left(Texte,y ) + Right(Texte,x-y)
SendMessage_(GadgetID(Gadget), #EM_SETSEL, x, x)
EndProcedure
Procedure convert(n)
If n = 1
SetGadgetText(4,Hex(Val(GetGadgetText(3))))
EndIf
If n = 2
SetGadgetText(3,Str(Val("$" + GetGadgetText(4))))
EndIf
If GetGadgetState(7) = 1
afcarac(Val(GetGadgetText(3)))
EndIf
EndProcedure
Procedure afcarac(nc)
If nc < 33
car$ = StringField(A$,nc+1,";")
Else
car$ = Chr(nc)
EndIf
If nc = 127:car$ = "DEL":EndIf
If nc = 160:car$ = "NBSP":EndIf
SetGadgetText(2,car$)
EndProcedure
Procedure carnum(car$)
If Len(car$) >1
SetGadgetText(2,UCase(car$))
GestionCaret(2)
car$ = GetGadgetText(2)
For c = 1 To 32
If car$ = StringField(A$,c+1,";")
num = c
Break
EndIf
Next
If car$ = "DEL" :num = 127:EndIf
If car$ = "NBSP" :num = 160:EndIf
SetGadgetText(3,Str(num))
convert(1)
Else
SetGadgetText(3,Str(Asc(GetGadgetText(2))))
convert(1)
EndIf
EndProcedure
OpenWindow(#Ma_fen,600,200,300,400,"Code Unicode",#PB_Window_BorderLess | #PB_Window_Invisible)
SetClassLongPtr_(WindowID(#Ma_fen),#GCL_STYLE,$00020000)
HideWindow(#Ma_fen,0)
StickyWindow(#Ma_fen,1)
; gadgets
N$ = " CODE UNICODE"
For x = 1 To Len(N$)
L$ = L$ + Mid(N$,x,1) + Chr(10)
Next
TextGadget(1,0,0,30,400,L$,#PB_Text_Center)
SetGadgetColor(1,#PB_Gadget_BackColor,$45DDB0)
SetGadgetFont(1,FontID1)
StringGadget(2,50,50,140,65,"NUL",#ES_CENTER)
SendMessage_(GadgetID(2),#EM_LIMITTEXT,4, 0)
SetGadgetFont(2,FontID2)
StringGadget(3,50,170,120,25,"0",#ES_CENTER|#PB_String_Numeric)
SetGadgetFont(3,FontID1)
StringGadget(4,50,235,120,25,"00",#ES_CENTER|#PB_String_UpperCase)
SetGadgetFont(4,FontID1)
ButtonGadget(5,210,177,40,40,"+")
SetGadgetFont(5,FontID1)
ButtonGadget(6,210,218,40,40,"-")
SetGadgetFont(6,FontID1)
CheckBoxGadget(7,50,290,180,25,"Recherche par numéro")
CheckBoxGadget(8,50,320,200,25,"Recherche par caractère")
ButtonGadget(9,62,360,80, 30,"Copie")
ButtonGadget(10,141,360,60, 30,"Raz")
ButtonGadget(11,200,360,80, 30,"Stop")
TextGadget(12,50,20,140,25,"Caractère",#PB_Text_Center)
TextGadget(13,50,140,120,25,"Code décimal",#PB_Text_Center)
TextGadget(14,50,205,140,25,"Code héxadécimal",#PB_Text_Center)
For b = 7 To 14
SetGadgetFont(b,FontID3)
Next
; Taches préparatoires
SetGadgetState(7,#PB_Checkbox_Checked)
Select(1)
; Boucle générale
Repeat
Event = WaitWindowEvent()
If Event = #WM_LBUTTONDOWN
SendMessage_(WindowID(#Ma_fen), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndIf
If Event = #PB_Event_Gadget
Select EventGadget()
Case 2 ;string caractere
Select EventType()
Case #PB_EventType_Change
carnum(GetGadgetText(2))
EndSelect
Case 3 ;string décimale
Select EventType()
Case #PB_EventType_Change
convert(1)
EndSelect
Case 4 ;string hexa
Select EventType()
Case #PB_EventType_Change
convert(2)
EndSelect
Case 5 ;bt +
p = Val(GetGadgetText(3))+1
SetGadgetText(3,Str(P))
convert(1)
Case 6 ;bt -
If Val(GetGadgetText(3)) > 0
M = Val(GetGadgetText(3)) -1
SetGadgetText(3,Str(M))
convert(1)
EndIf
Case 7 ;checKbox num
SetGadgetState(7,#PB_Checkbox_Checked)
SetGadgetState(8,#PB_Checkbox_Unchecked)
Select(1)
Case 8 ;checKbox car
SetGadgetState(8,#PB_Checkbox_Checked)
SetGadgetState(7,#PB_Checkbox_Unchecked)
For z = 3 To 4
SetGadgetText(z,"")
Next
Select(2)
SetActiveGadget(2)
Case 9 ;bt copie
ClearClipboard()
If GetGadgetState(7)= 1
SetClipboardText(GetGadgetText(2))
Else
SetClipboardText(GetGadgetText(4))
EndIf
Case 10 ;bt_raz
SetGadgetState(7,#PB_Checkbox_Checked)
SetGadgetState(8,#PB_Checkbox_Unchecked)
Select(3)
Case 11 ;bt_stop
CloseWindow(0)
Break
EndSelect
EndIf
ForEver
End