PureBasic Forum
https://www.purebasic.fr/english/

Display invisible chars in IDE
https://www.purebasic.fr/english/viewtopic.php?f=18&t=71650
Page 1 of 1

Author:  infratec [ Wed Oct 31, 2018 4:03 pm ]
Post subject:  Display invisible chars in IDE

Hi,

If I use a header map with Content-Type and other 'normal' headers it works a it should.
But this:
Code:
InitNetwork()

NewMap Header$()
Header$("Content-Type") = "application/json"
Header$("x-auth-token") = "​​123"

HTTPRequest(#PB_HTTP_Post, "http://www.purebasic.fr", "Test", 0, Header$())

Results in:
Quote:
x-auth-token: \342\200\213\342\200\213123\r\n
Content-Type: application/json\r\n

0090 41 63 63 65 70 74 3a 20 2a 2f 2a 0d 0a 78 2d 61 Accept: */*..x-a
00a0 75 74 68 2d 74 6f 6b 65 6e 3a 20 e2 80 8b e2 80 uth-token: â..â.
00b0 8b 31 32 33 0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 .123..Content-Ty
00c0 70 65 3a 20 61 70 70 6c 69 63 61 74 69 6f 6e 2f pe: application/
00d0 6a 73 6f 6e 0d 0a 43 6f 6e 74 65 6e 74 2d 4c 65 json..Content-Le

Independent of the string it puts $e2808b $e2808b in front of the string.

Very strange, since other custom headers works as expected.

Bernd

Author:  wayne-c [ Sat Nov 03, 2018 10:20 am ]
Post subject:  Re: PB 5.70b2 HTTPMemory() Header Map

I encountered a probably similar bug when sending a custom "Authorization" header with Base64-encoded Username:Password; as soon as there are accents (e.g. "é") inside the Password, the authorization is rejected by the service. I did not check with Wireshark what is actually transferred but I assume now that this could be the same error than yours and the Header is not transferred correctly!

Author:  infratec [ Sun Nov 04, 2018 10:29 am ]
Post subject:  Re: PB 5.70b2 HTTPMemory() Header Map

I did further investigations:

I changed the code and used libcurl directly.
With very strange results.

First I declared a constant for the authcode, since it is fixed in my application.
Code:
*headers = curl_slist_append(*headers, "X-Auth-Token: " + #X_Auth_Token$)

It fails in the same way.

The I thought: may be the string buffer is not avalaible when it is needed
and I used an extra variable.
Code:
Token$ = "X-Auth-Token: " + #X_Auth_Token$
*headers = curl_slist_append(*headers, Token$)

It fails in the same way.

Only working version:
Code:
*headers = curl_slist_append(*headers, "X-Auth-Token: 123456"


I use
Code:
curl_slist_append(slist.i, string.p-utf8)

for the import.

So 2 possibilities:
1. Something with p-utf8 is not 100% Ok
2. A bug in libcurls curl_slist_append()

I searched in the web for 2. but I found no informations about a bug.
Also a curl.exe request works as expected (Ok, there is also the complete string at once provided)

I have no chance to go deeper inside.

Bernd

Author:  Fred [ Mon Nov 19, 2018 2:16 pm ]
Post subject:  Re: PB 5.70b2 HTTPMemory() Header Map

I will take a look

Author:  Fred [ Mon Nov 19, 2018 10:16 pm ]
Post subject:  Re: PB 5.70b2 HTTPMemory() Header Map

I spend some time on this one, but it's not a PB bug: your string contains some hidden characters and PB create it like this in datasection for "123":

Code:
_S4: dw 8203,8203,49,50,51,0


As you can see, there is 2 extra character in the literal string. Just delete the string completely from the IDE and retype it and it will be gone.

Author:  infratec [ Tue Nov 20, 2018 8:34 am ]
Post subject:  Re: PB 5.70b2 HTTPMemory() Header Map

Hi Fred,

thank you for your time.
Originally I copied the string from an e-mail.

Then it was not working and I deleted it from the end via backspace and added 123.
Unfortunately the 2 hidden characters stayed.

But how should I know something about these characters? They are invisible.
Very strange.

I'll check if there are 24 different invisible characters available, then I'll write a procedure which allows to send 'invisible' text via e-mails :mrgreen:

Bernd

Author:  infratec [ Tue Nov 20, 2018 8:44 am ]
Post subject:  Re: [Solved]PB 5.70b2 HTTPMemory() Header Map

Unfortunately there are not 24 invisible characters available :wink:

https://en.wikipedia.org/wiki/Zero-width_space
https://en.wikipedia.org/wiki/Whitespace_character

For german readers:
https://de.wikipedia.org/wiki/Breitenloses_Leerzeichen

Author:  Fred [ Tue Nov 20, 2018 9:21 am ]
Post subject:  Re: [Solved]PB 5.70b2 HTTPMemory() Header Map

May be the IDE should display these, dunno if we can force scintilla to do so.

Edit: #SCI_SETREPRESENTATION seems the way to go, I will add some characters mapping in the IDE so it will be displayed

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/