Non-ASCII String(URL address) need to be escaped for WebBrowserComponent on OSX


#1

Otherwise, the webBrowserComponent’ll not load it and display nothing.

This issue only happens on OSX (10.12).

I used 2 static methods which come from Projucer’s source code to solve the problem. These 2 methods are: addEscapeChars() and writeEscapeChars(). Code example:

webBrowserComponent.goToURL (addEscapeChars (urlString).replace ("\\x", "%"));

Since Projucer is a commercial software, I don’t know whether it’s legal or not to use those 2 methods.

Hope this topic will help someone:)


#2

Can’t you use URL::addEscapeChars?


#3

Yes, I can, Fabian. but URL::addEscapeChars() will display nothing at all, just like the normal String-url which includes non-ascii chars. :slight_smile:

The reason: URL::addEscapeChars() 's escape-function is too powerful, even the ‘/’ also be escaped… :open_mouth:


#4

Ahhh ok makes sense… I’ll add something.


#5

The functions you’re using aren’t in the projucer, they’re just part of the C++ tokeniser, but I don’t recommend using them for URLs because they’re designed for a totally different purpose and some encodings may differ!


#6

I don’t know, Jules :slight_smile: I found those 2 useful methods in line 550/656 of jucer_UTF8Component.h (Projucer/Utility).

There’re exceptions. (again? :D) In my case, no need to play with any URL. I just need webBrowser goto a string (local html-file path) and display it correctly :slight_smile: I’m sure it’s a bad design though :slight_smile:


#7

I think you must be on a very old version?


#8

OS X: 10.12.2
Xcode: 8.2.1
JUCE: 4.3.0 (git master branch, pull the library yesterday night)

Seems the only thing is too old must be my brain :slight_smile:


#9

No, you really aren’t. This is the tip of master:
https://github.com/julianstorer/JUCE/blob/master/extras/Projucer/Source/Utility/jucer_UTF8Component.h


#10

In any case, I’ve added a fix for this on develop. Should be public very soon…


#11

Oh, yes, my fault :blush: I forgot I’ve ‘jumped to definition’…

Those 2 methods in gui_extra module of JUCE library, code_editor/cppCodeTokeniserFunctions.h


#12

:+1:!!

…20 words.