url encode utf8

Started by Cedric, November 27, 2024, 05:33:22 PM

Previous topic - Next topic

Cedric

Hi, is there a way to urlencode a string in UTF8?  I am trying to use the SMS tool with twilio and can't figure it out the encoding issues.  Actually, I did figure out why, but can't figure how to fix without creating my own function to encode and send the http request manually.

So, pvx sends the value "%E9" for the character "é" instead of "%C3%A9".  Obviously, this isn't UTF8 and twilio seems to only work with UTF8. So the result is that SMS has some unreadable characters.

I've tried pretty much every combos possible with CVS, but without success!

Anyone knows how to URL encode a string in UTF8?

 

Devon Austen

Are you creating your own interface to Twilio or using *tools/sms?

Our tool supports Twilio.
Principal Software Engineer for PVX Plus Technologies LTD.

Mike King

Have you tried CVS(string$, "ASCII:UTF8") to convert the data to UTF8?

If you need it HTML encoded, once you have the UTF8 string you can convert it to HTML using CVS(utf8data$, "NATIVE:HTML"); however this will yield é    (You can also use "ASCII:HTML")

->x$="This is test "+$e9$
->utf8$=cvs(x$,"ASCII:UTF8")
->print cvs(utf8$,"NATIVE:HTML")
This is test é
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Cedric

Hey guys,

yes, I am using *tools/sms and I confirm that it doesn't work with twilio if you use accented characters.
That being said, we did also create our own http request to twilio, but since I can't URL encode in UTF8, it won't work unless I implement my own URL encode function.

Mike, to answer your question, yes, I tried all of that and no... it doesn't work.  Twilio doesn't interpret html code... It literally sends this to SMS : "This is test é" .   

Mike King

If you want URL encoded with UTF-8 then use NATIVE:URL as in the following

->x$=$E9$
->utf8$=cvs(x$,"ASCII:UTF8")
->print cvs(utf8$,"NATIVE:URL")
%C3%A9
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Cedric

!*?*&?&%!&?%!&?%!&?!&?!%?&!
That is me screaming! loL!

I tried so many things Yesterday that I think I have changed the parameter U8... Now if I leave the default parameter that is set to 0, it works!   The only thing I need to do if I want to use the *tools/sms utility is to encode in UTF8... So MyMessageInUtf8$=cvs(MyMessage$,"NATIVE:UTF8") ...  I believe the utility already does the URL encode.

Thanks Mike for the tip. 

Mike King

Cedric

Glad to have been of assistance ... guess my little grey cells are still of some use.  Hercule Poirot would be pleased.  :)
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com