Just starting out? Need help? Post your questions and find answers here.
-
Wolf
- Enthusiast

- Posts: 234
- Joined: Sat Apr 03, 2004 12:00 pm
- Location: S.T
Post
by Wolf »
Hello everyone
How can i convert Html code like "۱۳" to clear text?
I get this html code when run this code:
Code: Select all
InitNetwork()
*Buffer = ReceiveHTTPMemory("http://zartools.com/zar/tools/time-date/date-f.php")
If *Buffer
Size = MemorySize(*Buffer)
Debug "Content: " + PeekS(*Buffer, Size, #PB_UTF8|#PB_ByteLength)
FreeMemory(*Buffer)
EndIf
When you open above URL in your browser you see clear result in page but when run above code in PB we get result in Html code like:
Code: Select all
چهارشنبه ۱۳ شهريور ۱۳۹۸</a></div>")
Last edited by
Wolf on Mon Sep 16, 2019 11:41 am, edited 2 times in total.
-
infratec
- Always Here

- Posts: 7620
- Joined: Sun Sep 07, 2008 12:45 pm
- Location: Germany
Post
by infratec »
Code: Select all
Procedure.s Decode(Text$)
Protected Length.i, Result$, Help$, Value$
Length = Len(Text$)
For i = 1 To Length
Char$ = Mid(Text$, i, 1)
If Char$ = "&"
Help$ = ""
Value$ = ""
While Help$ <> ";"
i + 1
Help$ = Mid(Text$, i, 1)
If Help$ <> "#" And Help$ <> ";"
Value$ + Help$
EndIf
Wend
Result$ + Chr(Val(Value$))
Else
Result$ + Char$
EndIf
Next i
ProcedureReturn Result$
EndProcedure
InitNetwork()
*Buffer = ReceiveHTTPMemory("http://1abzar.ir/abzar/tools/time-date/date-fa.php")
If *Buffer
Size = MemorySize(*Buffer)
Content$ = PeekS(*Buffer, Size, #PB_UTF8|#PB_ByteLength)
FreeMemory(*Buffer)
Pos1 = FindString(Content$, "#'>")
If Pos1
Pos1 + 3
Pos2 = FindString(Content$, "<", Pos1)
If Pos2
Text$ = Mid(Content$, Pos1, Pos2 - Pos1)
;Debug Text$
Debug Decode(Text$)
EndIf
EndIf
EndIf
-
Wolf
- Enthusiast

- Posts: 234
- Joined: Sat Apr 03, 2004 12:00 pm
- Location: S.T
Post
by Wolf »
Thank you so much infratec
Very fast and helpful.