Cinder-Protocol HttpServerApp UTF8


#1

Hello,

I test Cinder-Protocol with HttpServerApp and UTF8 character like é à…

I send with firefox :
>

            <div class="form-group">
                <label for="text_0">Text Box 0</label>
                <textarea name="text_0" class="form-control" rows="3"></textarea>
            </div>
            <div class="form-group">
                <label for="text_1">Text Box 1</label>
                <textarea name="text_1" class="form-control" rows="3"></textarea>
            </div>
            <div class="checkbox">
                <label>
                    <input type="checkbox" name="checkbox">A Check Box</input>
                </label>
            </div>
            <button type="submit" class="btn btn-default">Submit</button>
        </form>

After it display into firefox :

"text_0=éé
text_1=àà
checkbox=on
"

I receive in C++ console :

POST / HTTP/1.1
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
Connection:keep-alive
Content-Length:39
Content-Type:text/plain
Host:127.0.0.1:2000
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0
text_0=éé
text_1=Ã Ã
checkbox=on

I don’t understand why text_0 and text_1 is not well formated éé and à Ã

Any idea ?

Thanks


#2

Try adding the correct charset, see:
https://www.w3.org/International/articles/http-charset/index


#3

It was already added in httpServer code response C++ like :
mHttpResponse.setHeader( “Content-Type”, “text/html; charset=utf-8” );

and into html file like :
meta http-equiv=“Content-Type” content="text/html;charset=utf-8"
meta charset=“utf-8”

See file


#4

Could be that the output console only supports ASCII. I know that’s the case in Visual Studio.


#5

No the console display well the accent coded in UTF8

console() << “réquest :” << endl

work well !


#6

Any updates on this matter? Dis you sorted out colin?

I’m now coding in portuguese OS’s and will do some webservices request ans listeneners, so would aprecciate to render them in a TextBox.

EDIT: For future use of myself and other in non english OS’s this can remove runtime error, turnig all received/used string to UTF8:
> std::string temp;
> utf8::replace_invalid(originalString.begin(), originalString.end(), back_inserter(temp));

With #include “utf8cpp/checked.h”