How to read this 🔹 and print the emoji
How to read this 🔹 and print the emoji
Hi,
I want to be able to read 🔹 and show the emoji. This one and all the others.
Best Regards
I want to be able to read 🔹 and show the emoji. This one and all the others.
Best Regards
ARGENTINA WORLD CHAMPION
- NicTheQuick
- Addict
- Posts: 1514
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
- Contact:
Re: How to read this 🔹 and print the emoji
You actually can not store unicode characters above $ffff in a Purebasic string. Therefore you also can not show them without digging deeper into the functions your operating systems offers you.
But of course you can print that gibberish you just posted:
But of course you can print that gibberish you just posted:
Code: Select all
Debug "🔹"
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Re: How to read this 🔹 and print the emoji
ThanksNicTheQuick wrote:You actually can not store unicode characters above $ffff in a Purebasic string. Therefore you also can not show them without digging deeper into the functions your operating systems offers you.
But of course you can print that gibberish you just posted:Code: Select all
Debug "🔹"
I notice that i can do this:
Code: Select all
Emoji$ = "🔹"
For i = 1 To Len(Emoji$)
Debug Asc(Mid(Emoji$,i,1))
Next
;240 159 148 185 This is the decimal representation of that emoji
"You can find more exaple here 🔹 "
How to display it in webgadget? I tried using <meta charset="UTF-8">
I am reading thi from youtube, so i have no control over it.
ARGENTINA WORLD CHAMPION
Re: How to read this 🔹 and print the emoji
You are trying to show Unicode character U+1F539 (small blue diamond) right?
Code: Select all
Procedure.s ChrU(Codepoint.i)
If (Codepoint > $FFFF)
Result.s = " "
Codepoint - $10000
PokeU(@Result, $D800 + ((Codepoint >> 10) & $3FF))
PokeU(@Result + 2, $DC00 + (Codepoint & $3FF))
ProcedureReturn Result
ElseIf (Codepoint >= $0000)
ProcedureReturn Chr(Codepoint)
Else
ProcedureReturn ""
EndIf
EndProcedure
Debug ChrU($1F539) ; small blue diamond
Debug ""
string.s = "["
string.s + ChrU($26C4) ; snowman
string.s + ChrU($2708) ; plane
string.s + ChrU($1F600) ; face
string.s + ChrU($1F6B6) ; walker
string.s + ChrU($2733) ; burst
string.s + ChrU($203C) ; exclamation
string.s + ChrU($1F310) ; globe
string.s + ChrU($1F3C2) ; snowboard
string.s + ChrU($1F464) ; person
string.s + ChrU($1F50D) ; magnifier
string.s + "]"
Debug "Test string:"
Debug string
Debug "(You need a Debugger font which shows emojis!)"
Debug "(Or copy to another program)"
Re: How to read this 🔹 and print the emoji
Yes, its a samll blue diamond.kenmo wrote:You are trying to show Unicode character U+1F539 (small blue diamond) right?
Code: Select all
Procedure.s ChrU(Codepoint.i) If (Codepoint > $FFFF) Result.s = " " Codepoint - $10000 PokeU(@Result, $D800 + ((Codepoint >> 10) & $3FF)) PokeU(@Result + 2, $DC00 + (Codepoint & $3FF)) ProcedureReturn Result ElseIf (Codepoint >= $0000) ProcedureReturn Chr(Codepoint) Else ProcedureReturn "" EndIf EndProcedure Debug ChrU($1F539) ; small blue diamond Debug "" string.s = "[" string.s + ChrU($26C4) ; snowman string.s + ChrU($2708) ; plane string.s + ChrU($1F600) ; face string.s + ChrU($1F6B6) ; walker string.s + ChrU($2733) ; burst string.s + ChrU($203C) ; exclamation string.s + ChrU($1F310) ; globe string.s + ChrU($1F3C2) ; snowboard string.s + ChrU($1F464) ; person string.s + ChrU($1F50D) ; magnifier string.s + "]" Debug "Test string:" Debug string Debug "(You need a Debugger font which shows emojis!)" Debug "(Or copy to another program)"
How i convert 🔹 into $1F539 ??
Remember that I AM NOT have control, im reading that from Youtube descriptions.
I need to detect it into the string (text)... or maybe there is some HTML way to show directly 🔹 into the small blue diamon?
ARGENTINA WORLD CHAMPION
Re: How to read this 🔹 and print the emoji
Something like this
But, all this should not be needed if I better understood your input and your output...
Are you reading from a file? Or from a memory buffer? ASCII? UTF-8?
Back out to a file? Or a memory buffer?
With the right formats of PeekS() and PokeS() or ReadString() and WriteString()
you should be able to handle this with just PB functions, no extra conversions.
If you can trim it down to some running code, we could help improve it.
Code: Select all
Procedure.s Convert(Text.s)
*Ascii = Ascii(Text) ; put it into an ASCII buffer
Result.s = PeekS(*Ascii, -1, #PB_UTF8) ; read it back as UTF-8
FreeMemory(*Ascii)
ProcedureReturn Result
EndProcedure
RawString.s = "🔹" ; chars intended to be UTF-8 emoji
NewString.s = Convert(RawString)
Debug RawString
Debug NewString
; Inspect an emoji to get the Unicode hex value...
Procedure.i AscU(String.s)
CompilerIf (#PB_Compiler_Unicode)
Protected First.i = Asc(String)
If ((First >= $D800) And (First <= $DBFF))
Protected Second.i = PeekC(@String + SizeOf(CHARACTER))
If ((Second >= $DC00) And (Second <= $DFFF))
First = (First & $03FF) << 10
First | (Second & $03FF)
First + $010000
EndIf
EndIf
ProcedureReturn (First)
CompilerElse
ProcedureReturn (Asc(String))
CompilerEndIf
EndProcedure
Debug "$" + Hex( AscU(NewString) )
But, all this should not be needed if I better understood your input and your output...
Are you reading from a file? Or from a memory buffer? ASCII? UTF-8?
Back out to a file? Or a memory buffer?
With the right formats of PeekS() and PokeS() or ReadString() and WriteString()
you should be able to handle this with just PB functions, no extra conversions.
If you can trim it down to some running code, we could help improve it.
Re: How to read this 🔹 and print the emoji
Thanks for your answer.kenmo wrote:Something like this
Code: Select all
Procedure.s Convert(Text.s) *Ascii = Ascii(Text) ; put it into an ASCII buffer Result.s = PeekS(*Ascii, -1, #PB_UTF8) ; read it back as UTF-8 FreeMemory(*Ascii) ProcedureReturn Result EndProcedure RawString.s = "🔹" ; chars intended to be UTF-8 emoji NewString.s = Convert(RawString) Debug RawString Debug NewString ; Inspect an emoji to get the Unicode hex value... Procedure.i AscU(String.s) CompilerIf (#PB_Compiler_Unicode) Protected First.i = Asc(String) If ((First >= $D800) And (First <= $DBFF)) Protected Second.i = PeekC(@String + SizeOf(CHARACTER)) If ((Second >= $DC00) And (Second <= $DFFF)) First = (First & $03FF) << 10 First | (Second & $03FF) First + $010000 EndIf EndIf ProcedureReturn (First) CompilerElse ProcedureReturn (Asc(String)) CompilerEndIf EndProcedure Debug "$" + Hex( AscU(NewString) )
But, all this should not be needed if I better understood your input and your output...
Are you reading from a file? Or from a memory buffer? ASCII? UTF-8?
Back out to a file? Or a memory buffer?
With the right formats of PeekS() and PokeS() or ReadString() and WriteString()
you should be able to handle this with just PB functions, no extra conversions.
If you can trim it down to some running code, we could help improve it.
I am NOT using the PB functions to rd the HTML code because for some reason im not getting HTML but a crazy javascript response. Then i am using this funtions to get the page description of any videoand i am pasring the title, views, suscribers, tags, description... but in the description shows many emojis sometimes:
I am using this funtion to read YT description:
Code: Select all
Procedure.S HTTPRequestURL(url.S, ReturnType = 1, PostData.S = "", Cookie.S = "", User_agent.S = "", Referer.S = "", File_to_download.S = "", Proxy.S = "", Timeout.L = 30000, Redirect.b = #True)
;{ Format URL
If FindString(url, "https://", 1, #PB_String_NoCase)
Is_secure.b = #True
EndIf
url = RemoveString(url, "https://", #PB_String_NoCase)
url = RemoveString(url, "http://", #PB_String_NoCase)
Host.S = StringField(url, 1, "/")
page.S = RemoveString(url, Host, #PB_String_NoCase)
page.S = RTrim(page, "/")
;}
;{ Add headers
If Not Proxy = "" : Access_type.i = 3 : Else : Access_type.i = 1 : EndIf
If User_agent = "" : User_agent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" : EndIf
Open_handle = InternetOpen_(User_agent, Access_type, Proxy, "", 0)
InternetSetOption_(Open_handle, 2, @Timeout, 4)
InternetSetOption_(Open_handle, 5, @Timeout, 4) ; #INTERNET_OPTION_SEND_TIMEOUT
InternetSetOption_(Open_handle, 6, @Timeout, 4) ; #INTERNET_OPTION_RECEIVE_TIMEOUT
InternetSetOption_(Open_handle, 7, @Timeout, 4) ; #INTERNET_OPTION_DATA_SEND_TIMEOUT
InternetSetOption_(Open_handle, 8, @Timeout, 4) ; #INTERNET_OPTION_DATA_RECEIVE_TIMEOUT
If Is_secure : Port.i = 443 : Flag.L = $00800000|$00001000|$00002000|$00080000|$00000100|$04000000
Else : Port.i = 80 : Flag.L = $00080000|$00000100|$04000000 : EndIf
If Not Redirect : Flag|$00200000 : EndIf
If Not PostData = "" : Verb.S = "POST" : Else : Verb.S = "GET" : EndIf
If page = "" : page = "/" : EndIf
Connect_handle = InternetConnect_(Open_handle, Host, Port, "", "", 3, 0, 0)
Request_handle = HttpOpenRequest_(Connect_handle, Verb, page, "", Referer, 0, Flag, 0)
If Verb = "POST"
Headers.S = "Content-Type: application/x-www-form-urlencoded" + Chr(13) + Chr(10)
HttpAddRequestHeaders_(Request_handle, Headers, Len(Headers), $80000000|$20000000)
EndIf
If Not Cookie = ""
Headers.S = "Cookie: " + Cookie + Chr(13) + Chr(10)
HttpAddRequestHeaders_(Request_handle, Headers, Len(Headers), $80000000|$20000000)
EndIf
;}
;{ Send request
If #PB_Compiler_Unicode
*PostDataAnsi = AllocateMemory(StringByteLength(PostData, #PB_Ascii) + 1)
PokeS(*PostDataAnsi, PostData, -1, #PB_Ascii)
Send_handle = HttpSendRequest_(Request_handle, "", 0, *PostDataAnsi, StringByteLength(PostData, #PB_Ascii))
FreeMemory(*PostDataAnsi)
Else
Send_handle = HttpSendRequest_(Request_handle, "", 0, PostData, Len(PostData))
EndIf
;}
;{ Receive response
If ReturnType = 1 ; Return server response content
buffer.S = Space(1024)
Repeat
InternetReadFile_(Request_handle, @buffer, 1024, @Bytes_read.L)
Result1.S + Left(PeekS(@buffer,-1,#PB_Ascii), Bytes_read)
buffer = Space(1024)
Until Bytes_read = 0
ElseIf ReturnType = 2; Return Cookie(s)
For i = 0 To 9
buffer.S = Space(1024)
Headernum = i
length = Len(buffer)
If HttpQueryInfo_(Request_handle, 43, @buffer, @length, @Headernum)
Result1.S + buffer + #CRLF$
EndIf
Next
ElseIf ReturnType = 3; Return both
For i = 0 To 9
buffer.S = Space(1024)
Headernum = i
length = Len(buffer)
If HttpQueryInfo_(Request_handle, 43, @buffer, @length, @Headernum)
Result1.S + buffer + #CRLF$
EndIf
Next
Result1 + #CRLF$
buffer.S = Space(1024)
Repeat
InternetReadFile_(Request_handle, @buffer, 1024, @Bytes_read.L)
Result1.S + Left(PeekS(@buffer,-1,#PB_Ascii), Bytes_read)
buffer = Space(1024)
Until Bytes_read = 0
ElseIf ReturnType = 4; Download file
If File_to_download <> ""
Filehandle = CreateFile(#PB_Any, File_to_download)
fBytes.L = 0
Loop.b = 1
fBuffer = AllocateMemory(4096)
Repeat
InternetReadFile_(Request_handle, fBuffer, 4096, @Bytes_read.L)
If Bytes_read = 0
Loop = 0
Else
fBytes = fBytes + Bytes_read
WriteData(Filehandle, fBuffer, Bytes_read)
EndIf
Until Loop = 0
CloseFile(Filehandle)
Result1 = Str(FileSize(File_to_download))
FreeMemory(fBuffer)
Else
Result1 = ""
EndIf
ElseIf ReturnType = 5 ; return redirected URl + cookies
For i = 0 To 9
buffer.S = Space(1024)
Headernum = i
length = Len(buffer)
If HttpQueryInfo_(Request_handle, 43, @buffer, @length, @Headernum)
Result1.S + buffer + #CRLF$
EndIf
Next
buffer.S = Space(#MAX_PATH)
Headernum = 0
length = Len(buffer)
If HttpQueryInfo_(Request_handle, 33, @buffer, @length, @Headernum)
Result1 = buffer + #CRLF$ + Result1
EndIf
EndIf
;}
;{ Close handle
InternetCloseHandle_(Open_handle)
InternetCloseHandle_(Connect_handle)
InternetCloseHandle_(Request_handle)
InternetCloseHandle_(Send_handle)
Delay(70)
;}
ProcedureReturn Result1
EndProcedure
Im getting this kind of string that i want to show in a webgadget:
"<br /><br />✅ Todos los recursos mencionados en el video los puedes encontrar en el comentario fijado que lo encontraras abajo 👇ðŸ»ðŸ‘‡ðŸ»ðŸ‘‡ðŸ»"
ARGENTINA WORLD CHAMPION
- NicTheQuick
- Addict
- Posts: 1514
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
- Contact:
Re: How to read this 🔹 and print the emoji
Just use the Youtube API to get information about videos. It's the only thing you can get the information right everytime. The HTML output can change every moment: https://developers.google.com/youtube/v3
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Re: How to read this 🔹 and print the emoji
Yes, but i dont wanrt to use the Youtube API.NicTheQuick wrote:Just use the Youtube API to get information about videos. It's the only thing you can get the information right everytime. The HTML output can change every moment: https://developers.google.com/youtube/v3
Rightnow i already reolve everything about getting oputput changes, i just need the emoji stuff.... and i think that i will need it even if i use the API, because i wanrt to get the emojis in the description.
ARGENTINA WORLD CHAMPION
Re: How to read this 🔹 and print the emoji
There are 2 possible solutions here:
1.- Find how to make Webgadget display 🔹 as a small blue diamond
2.- Find how to get from 🔹 to this format 🔹 for that emoji... or from the decimal 240 159 148 185 to the 🔹
No matter if i scrap YT or use the YT API, at the end i will face the same emoji problem.
1.- Find how to make Webgadget display 🔹 as a small blue diamond
2.- Find how to get from 🔹 to this format 🔹 for that emoji... or from the decimal 240 159 148 185 to the 🔹
No matter if i scrap YT or use the YT API, at the end i will face the same emoji problem.
ARGENTINA WORLD CHAMPION
Re: How to read this 🔹 and print the emoji
I find this info:
The result is 240 159 148 185
Debug Hex(240,#PB_Byte )
Debug Hex(159,#PB_Byte )
Debug Hex(148,#PB_Byte )
Debug Hex(185,#PB_Byte )
Get F0 9F 94 B9
I need to go fro0m there to 🔹
'
As i alredy show i can get tge dec(bytes) by this way:
Unicode number U+1F539
HTML-code 🔹
CSS-code \1F539
Encoding...hex.................dec (bytes).....................dec..............binary
UTF-8.......F0 9F 94 B9........240 159 148 185......4036990137.....11110000 10011111 10010100 10111001
Code: Select all
Emoji$ = "🔹"
For i = 1 To Len(Emoji$)
Debug Asc(Mid(Emoji$,i,1))
Debug Hex(Val(Mid(Emoji$,i,1)))
Next
Debug Hex(240,#PB_Byte )
Debug Hex(159,#PB_Byte )
Debug Hex(148,#PB_Byte )
Debug Hex(185,#PB_Byte )
Get F0 9F 94 B9
I need to go fro0m there to 🔹
'
ARGENTINA WORLD CHAMPION
- NicTheQuick
- Addict
- Posts: 1514
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
- Contact:
Re: How to read this 🔹 and print the emoji
I guess you are looking for this:
I borrowed it from here: Wikipedia - UTF-8
It works with UTF-8 characters with a length from 1 to 4 bytes. I also does some error checking.
Code: Select all
Procedure.i unicodeValue(a.a, b.a = 0, c.a = 0, d.a = 0)
If (a & $80 = 0)
ProcedureReturn a & $7f
ElseIf (a & $e0 = $c0) And (b & $c0 = $80)
ProcedureReturn ((a & $1f) << 6) | (b & $3f)
ElseIf (a & $f0 = $e0) And (b & $c0 = $80) And (c & $c0 = $80)
ProcedureReturn ((a & $f) << 12) | ((b & $3f) << 6) | (c & $3f)
ElseIf (a & $f8 = $f0) And (b & $c0 = $80) And (c & $c0 = $80) And (d & $c0 = $80)
ProcedureReturn ((a & $7) << 18) | ((b & $3f) << 12) | ((c & $3f) << 6) | (d & $3f)
EndIf
Debug "Invalid UTF-8 character."
ProcedureReturn -1
EndProcedure
Debug unicodeValue(240, 159, 148, 185)
Debug Hex(unicodeValue(240, 159, 148, 185))
It works with UTF-8 characters with a length from 1 to 4 bytes. I also does some error checking.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Re: How to read this 🔹 and print the emoji
Ricardo, friend, I still think you're tackling the wrong problem. You shouldn't have to do these extra conversions.
You only have that nonsense string because, at some earlier point, you are interpreting UTF-8 byte data as plain ASCII text.
Changing some of your #PB_Ascii PeekS() to #PB_UTF8 PeekS() should convert those byte sequences to the correct Unicode text you expect.
Could you post more than that procedure? A working test program we could run?
Also: I hope you're using PB 5.72 because there was a fix for displaying Unicode characters (like emoji) in WebGadgets.
You only have that nonsense string because, at some earlier point, you are interpreting UTF-8 byte data as plain ASCII text.
Changing some of your #PB_Ascii PeekS() to #PB_UTF8 PeekS() should convert those byte sequences to the correct Unicode text you expect.
Could you post more than that procedure? A working test program we could run?
Also: I hope you're using PB 5.72 because there was a fix for displaying Unicode characters (like emoji) in WebGadgets.
Re: How to read this 🔹 and print the emoji
I am using 5.72kenmo wrote:Ricardo, friend, I still think you're tackling the wrong problem. You shouldn't have to do these extra conversions.
You only have that nonsense string because, at some earlier point, you are interpreting UTF-8 byte data as plain ASCII text.
Changing some of your #PB_Ascii PeekS() to #PB_UTF8 PeekS() should convert those byte sequences to the correct Unicode text you expect.
Could you post more than that procedure? A working test program we could run?
Also: I hope you're using PB 5.72 because there was a fix for displaying Unicode characters (like emoji) in WebGadgets.
I was using
Code: Select all
*Buffer = ReceiveHTTPMemory("https://www.youtube.com/results?search_query=" + Keyword$)
If *Buffer
Size = MemorySize(*Buffer)
xyHTMLContenido$ = PeekS(*Buffer, Size, #PB_UTF8|#PB_ByteLength)
Code: Select all
Procedure.S HTTPRequestURL(url.S, ReturnType = 1, PostData.S = "", Cookie.S = "", User_agent.S = "", Referer.S = "", File_to_download.S = "", Proxy.S = "", Timeout.L = 30000, Redirect.b = #True)
;{ Format URL
If FindString(url, "https://", 1, #PB_String_NoCase)
Is_secure.b = #True
EndIf
url = RemoveString(url, "https://", #PB_String_NoCase)
url = RemoveString(url, "http://", #PB_String_NoCase)
Host.S = StringField(url, 1, "/")
page.S = RemoveString(url, Host, #PB_String_NoCase)
page.S = RTrim(page, "/")
;}
;{ Add headers
If Not Proxy = "" : Access_type.i = 3 : Else : Access_type.i = 1 : EndIf
If User_agent = "" : User_agent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" : EndIf
Open_handle = InternetOpen_(User_agent, Access_type, Proxy, "", 0)
InternetSetOption_(Open_handle, 2, @Timeout, 4)
InternetSetOption_(Open_handle, 5, @Timeout, 4) ; #INTERNET_OPTION_SEND_TIMEOUT
InternetSetOption_(Open_handle, 6, @Timeout, 4) ; #INTERNET_OPTION_RECEIVE_TIMEOUT
InternetSetOption_(Open_handle, 7, @Timeout, 4) ; #INTERNET_OPTION_DATA_SEND_TIMEOUT
InternetSetOption_(Open_handle, 8, @Timeout, 4) ; #INTERNET_OPTION_DATA_RECEIVE_TIMEOUT
If Is_secure : Port.i = 443 : Flag.L = $00800000|$00001000|$00002000|$00080000|$00000100|$04000000
Else : Port.i = 80 : Flag.L = $00080000|$00000100|$04000000 : EndIf
If Not Redirect : Flag|$00200000 : EndIf
If Not PostData = "" : Verb.S = "POST" : Else : Verb.S = "GET" : EndIf
If page = "" : page = "/" : EndIf
Connect_handle = InternetConnect_(Open_handle, Host, Port, "", "", 3, 0, 0)
Request_handle = HttpOpenRequest_(Connect_handle, Verb, page, "", Referer, 0, Flag, 0)
If Verb = "POST"
Headers.S = "Content-Type: application/x-www-form-urlencoded" + Chr(13) + Chr(10)
HttpAddRequestHeaders_(Request_handle, Headers, Len(Headers), $80000000|$20000000)
EndIf
If Not Cookie = ""
Headers.S = "Cookie: " + Cookie + Chr(13) + Chr(10)
HttpAddRequestHeaders_(Request_handle, Headers, Len(Headers), $80000000|$20000000)
EndIf
;}
;{ Send request
If #PB_Compiler_Unicode
*PostDataAnsi = AllocateMemory(StringByteLength(PostData, #PB_Ascii) + 1)
PokeS(*PostDataAnsi, PostData, -1, #PB_Ascii)
Send_handle = HttpSendRequest_(Request_handle, "", 0, *PostDataAnsi, StringByteLength(PostData, #PB_Ascii))
FreeMemory(*PostDataAnsi)
Else
Send_handle = HttpSendRequest_(Request_handle, "", 0, PostData, Len(PostData))
EndIf
;}
;{ Receive response
If ReturnType = 1 ; Return server response content
buffer.S = Space(1024)
Repeat
InternetReadFile_(Request_handle, @buffer, 1024, @Bytes_read.L)
Result1.S + Left(PeekS(@buffer,-1,#PB_Ascii), Bytes_read)
buffer = Space(1024)
Until Bytes_read = 0
ElseIf ReturnType = 2; Return Cookie(s)
For i = 0 To 9
buffer.S = Space(1024)
Headernum = i
length = Len(buffer)
If HttpQueryInfo_(Request_handle, 43, @buffer, @length, @Headernum)
Result1.S + buffer + #CRLF$
EndIf
Next
ElseIf ReturnType = 3; Return both
For i = 0 To 9
buffer.S = Space(1024)
Headernum = i
length = Len(buffer)
If HttpQueryInfo_(Request_handle, 43, @buffer, @length, @Headernum)
Result1.S + buffer + #CRLF$
EndIf
Next
Result1 + #CRLF$
buffer.S = Space(1024)
Repeat
InternetReadFile_(Request_handle, @buffer, 1024, @Bytes_read.L)
Result1.S + Left(PeekS(@buffer,-1,#PB_Ascii), Bytes_read)
buffer = Space(1024)
Until Bytes_read = 0
ElseIf ReturnType = 4; Download file
If File_to_download <> ""
Filehandle = CreateFile(#PB_Any, File_to_download)
fBytes.L = 0
Loop.b = 1
fBuffer = AllocateMemory(4096)
Repeat
InternetReadFile_(Request_handle, fBuffer, 4096, @Bytes_read.L)
If Bytes_read = 0
Loop = 0
Else
fBytes = fBytes + Bytes_read
WriteData(Filehandle, fBuffer, Bytes_read)
EndIf
Until Loop = 0
CloseFile(Filehandle)
Result1 = Str(FileSize(File_to_download))
FreeMemory(fBuffer)
Else
Result1 = ""
EndIf
ElseIf ReturnType = 5 ; return redirected URl + cookies
For i = 0 To 9
buffer.S = Space(1024)
Headernum = i
length = Len(buffer)
If HttpQueryInfo_(Request_handle, 43, @buffer, @length, @Headernum)
Result1.S + buffer + #CRLF$
EndIf
Next
buffer.S = Space(#MAX_PATH)
Headernum = 0
length = Len(buffer)
If HttpQueryInfo_(Request_handle, 33, @buffer, @length, @Headernum)
Result1 = buffer + #CRLF$ + Result1
EndIf
EndIf
;}
;{ Close handle
InternetCloseHandle_(Open_handle)
InternetCloseHandle_(Connect_handle)
InternetCloseHandle_(Request_handle)
InternetCloseHandle_(Send_handle)
Delay(70)
;}
ProcedureReturn Result1
EndProcedure
I only get the result from a YT webpage like https://www.youtube.com/watch?v=tfOOwD2kmkE and inside the description (not the short one, but the com plete) i found all this strange emojis.
This exact page was the one that shows all this emojis https://www.youtube.com/watch?v=tfOOwD2kmkE
ARGENTINA WORLD CHAMPION
Re: How to read this 🔹 and print the emoji
This works for me:
if you just change #PB_Ascii to #PB_UTF8 in ReturnType 1 and 3
Code: Select all
InitNetwork()
Response.s = HTTPRequestURL("https://www.youtube.com/watch?v=tfOOwD2kmkE", 1)
Text.s = StringField(Response, 2, "HECq3V4TcwA\\n\\n")
Text.s = StringField(Text, 1, "Otros videos con ")
Debug Text
Debug "^ Should be diamonds"
Debug "^ Need a Debugger font that supports emoji (or copy this elsewhere)"