|
|
Subject: Re: how to decode correctly unicode http parameters? - msg#00097
List: ai.prolog.swi
On Friday 28 April 2006 16:08, Jan Wielemaker wrote:
> Ilmars,
>
> On Friday 28 April 2006 15:54, Ilmars Poikans wrote:
> > I tried but without success, to retrieve correctly HTTP GET or POST
> > parameters, which containcs unicode characters. See, file in attachment.
> > After running it, you can open http://localhost:88/ and see that form
> > contains correct Unicode chars, but after submitting POST or GET, Unicode
> > characters get corrupted. As I understand parameters are retrieved in one
> > byte character set, not utf8. How to force
> >
> > http_parameters(Request, [sentence(Sentence, [default('Some text with
> > unicode character: ÄÄÄÄÄÄÄÅÅÅÅÄÄÄÄÄÄÅÅÅÅ')])]),
> >
> > to use utf8 when reading form data (default value is fine)?
>
> It should detect the encoding used by the one sending the POST.
> Appearently this is not yet implemented. Unfortunately I'm very busy
> right now to go on holidays on monday for the rest of may. So I'm
> afraid you have to dig into the code yourself :-(
>
> If you do not want this to be forgotten, submit a report at the SWI-Prolog
> Bugzilla. Even better, attach a patch to the report :-)
Oh, if you have the string in UTF-8 and want to create Unicode from it,
there is a DCG called utf8_string//1 in library rdf_parser.pl that does
that for you. This however is only a work-around; http_parameters should
do the job for you without you noticing it.
Cheers --- Jan
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
how to decode correctly unicode http parameters?
Hi,
I tried but without success, to retrieve correctly HTTP GET or POST parameters,
which containcs
unicode characters. See, http://www.delibero.lv/serverform.pl . After running it, you can open
http://localhost:88/ and see that form contains correct Unicode chars, but after submitting POST or
GET, Unicode characters get corrupted. As I understand parameters are retrieved in one byte
character set, not utf8. How to force
http_parameters(Request, [sentence(Sentence, [default('Some text with unicode
character:
some unicode chars')])]),
to use utf8 when reading form data (default value is fine)?
I'm using SWI-Prolog version 5.6.12 on Windows XP SP2
Best regards,
Ilmars Poikans
P.S. Sorry, if I managed to post this message several times. It seemed to me, that attached pl files
didn't get through at some point between me and mailning list.
Next Message by Date:
click to view message preview
Changing the font in PC_emacs.
I've been trying out PC_emacs.
I think that PC_emacs has got some useful features,
that my usual editor does not have.
But the text is not displayed very clearly on my monitor ;
the font is not very good.
Is there a way to change the font?
Ideally I'd like it to use Times New Roman, size 12.
This font looks good on my monitor.
Its what I use in my usual editor.
I'm using SWI Prolog 5.6.0, with XPCE 6.6.0, running under Windows XP.
--
Martin Sondergaard,
London.
Previous Message by Thread:
click to view message preview
Re: how to decode correctly unicode http parameters?
Ilmars,
On Friday 28 April 2006 15:54, Ilmars Poikans wrote:
> I tried but without success, to retrieve correctly HTTP GET or POST
> parameters, which containcs unicode characters. See, file in attachment.
> After running it, you can open http://localhost:88/ and see that form
> contains correct Unicode chars, but after submitting POST or GET, Unicode
> characters get corrupted. As I understand parameters are retrieved in one
> byte character set, not utf8. How to force
>
> http_parameters(Request, [sentence(Sentence, [default('Some text with
> unicode character: ÄÄÄÄÄÄÄÅÅÅÅÄÄÄÄÄÄÅÅÅÅ')])]),
>
> to use utf8 when reading form data (default value is fine)?
It should detect the encoding used by the one sending the POST.
Appearently this is not yet implemented. Unfortunately I'm very busy
right now to go on holidays on monday for the rest of may. So I'm
afraid you have to dig into the code yourself :-(
If you do not want this to be forgotten, submit a report at the SWI-Prolog
Bugzilla. Even better, attach a patch to the report :-)
Sorry --- Jan
Next Message by Thread:
click to view message preview
how to decode correctly unicode http parameters?
Hi,
I tried but without success, to retrieve correctly HTTP GET or POST parameters,
which containcs
unicode characters. See, file in attachment. After running it, you can open
http://localhost:88/ and
see that form contains correct Unicode chars, but after submitting POST or GET,
Unicode characters
get corrupted. As I understand parameters are retrieved in one byte character
set, not utf8. How to
force
http_parameters(Request, [sentence(Sentence, [default('Some text with unicode
character:
some unicode chars')])]),
to use utf8 when reading form data (default value is fine)?
I'm using SWI-Prolog version 5.6.12 on Windows XP SP2
Best regards,
Ilmars Poikans
:- use_module(library('http/thread_httpd')).
:- use_module(library('http/http_parameters')).
:- http_server(reply, [port(88)]).
reply(Request) :-
memberchk(path(Path), Request), !,
reply(Path, Request).
reply('/', Request) :-
http_parameters(Request, [sentence(Sentence, [default('Some text with
unicode character: Ä?Ä?Ä?ĢĪĶĻÅ?ŠŪŽÄ?Ä?ģīķļÅ?šūž')])]),
format('Content-type: text/html~n~n', []),
writeln('<HTML>'),
writeln('<BODY>'),
writeln('<CENTER>'),
writeln('<FORM action="/" method="POST">'),
writeln('Sentence:<BR>'),
write('<TEXTAREA name="sentence" cols="40" rows="6">'),
write(Sentence),
writeln('</TEXTAREA><BR>'),
writeln('<INPUT TYPE="submit" VALUE="POST">'),
writeln('</FORM>'),
writeln('<FORM action="/" method="GET">'),
writeln('Sentence:<BR>'),
write('<TEXTAREA name="sentence" cols="40" rows="6">'),
write(Sentence),
writeln('</TEXTAREA><BR>'),
writeln('<INPUT TYPE="submit" VALUE="GET">'),
writeln('</FORM>'),
format('<table border=1>~n'),
print_request(Request),
format('~n</table>~n'),
writeln('</CENTER>'),
writeln('</BODY>'),
writeln('</HTML>').
print_request([]).
print_request([H|T]) :-
H =.. [Name, Value],
format('<tr><td>~w<td>~w~n', [Name, Value]),
print_request(T).
|
|