Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

apache rivet 3.0 and UTF-8 in tcl

62 views
Skip to first unread message

P8j6

unread,
Sep 20, 2018, 10:46:35 AM9/20/18
to
Hi,

how can i configure rivet 3.0 to work with utf-8 characters in tcl files?

On server, I have this simple page: test.tcl, saved with utf-8 encoding

puts {
<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="UTF-8">
<title>videoLib</title>
</head>
<body>
}

puts {
<form method="post">
<input type="text" name="fullname" value="Zkušební řetězec">
<button>Submit</button>
</form>
}

puts {

</body>
</html>
}

Apache is configured to work with UTF-8.

In apache2.conf i have: AddDefaultCharset UTF-8
And in rivet.conf i have:

<IfModule mod_rivet.c>
AddType "application/x-httpd-rivet;charset=utf-8" rvt
AddType "application/x-rivet-tcl;charset=utf-8" tcl
RivetServerConf SeparateVirtualInterps yes
</IfModule>

And yet, in browser, if i visit: http://127.0.0.1/test.tcl
The text "Zkušební řetězec" comes garbled.

Thanks for any hint or help!



Rich

unread,
Sep 20, 2018, 11:31:37 AM9/20/18
to
P8j6 <jureck...@gmail.com> wrote:
> Hi,
>
> how can i configure rivet 3.0 to work with utf-8 characters in tcl files?
>
> On server, I have this simple page: test.tcl, saved with utf-8 encoding
>
> puts {
> <!DOCTYPE html>
> <html lang="cs">
> ...
> And yet, in browser, if i visit: http://127.0.0.1/test.tcl
> The text "Zku?ební ?et?zec" comes garbled.

What happens, if you add this line at the start of your 'test.tcl'
file?:

fconfigure stdout -encoding utf-8

P8j6

unread,
Sep 20, 2018, 11:39:20 AM9/20/18
to
Dne čtvrtek 20. září 2018 17:31:37 UTC+2 Rich napsal(a):
Nothing. Text remain garbled.

I think, stdout channel should be utf-8 configured before test.tcl is loaded by server. But i dont know where to put it.

I also tried put it into the BeforeScript directive:

RivetServerConf BeforeScript "fconfigure stdout -encoding utf-8"

But it doesn't help either.

Rich

unread,
Sep 20, 2018, 12:15:50 PM9/20/18
to
P8j6 <jureck...@gmail.com> wrote:
> Dne ?tvrtek 20. zá?í 2018 17:31:37 UTC+2 Rich napsal(a):
This suggests then that somewhere within the remainder of the channel
between Tcl and the ultimate browser that there is an encoding setting
that is not yet set correctly.

What http headers does your server offer up when you browse to it?

Rich

unread,
Sep 20, 2018, 1:16:04 PM9/20/18
to
P8j6 <jureck...@gmail.com> wrote:
> <IfModule mod_rivet.c>

This should likely say ".o" not ".c".

Do you have ".c" in your actual config file? If yes, try changing it
to ".o" and see if that makes a difference.

P8j6

unread,
Sep 20, 2018, 1:19:17 PM9/20/18
to
Dne čtvrtek 20. září 2018 18:15:50 UTC+2 Rich napsal(a):
These are headers from Firefox, when i visit my test.tcl page:

REQUEST:
GET /test.tcl HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:58.0) Gecko/20100101 Firefox/58.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Pragma: no-cache
Cache-Control: no-cache

RESPONSE:
HTTP/1.1 200 OK
Date: Thu, 20 Sep 2018 17:11:32 GMT
Server: Apache/2.4.34 (Debian)
Vary: Accept-Encoding
Content-Encoding: gzip
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html;charset=utf-8




P8j6

unread,
Sep 20, 2018, 1:27:31 PM9/20/18
to
Dne čtvrtek 20. září 2018 19:16:04 UTC+2 Rich napsal(a):
> P8j6 wrote:
> > <IfModule mod_rivet.c>
>
> This should likely say ".o" not ".c".
>
> Do you have ".c" in your actual config file? If yes, try changing it
> to ".o" and see if that makes a difference.

Yes, there is .c. Its from stock configuration from debian package.

I tried replace .c to .o. And after server restart its stopped working. I just got tcl filed download instead being processed.

So .c looks valid.

Rich

unread,
Sep 20, 2018, 1:34:47 PM9/20/18
to
P8j6 <jureck...@gmail.com> wrote:
> Dne ?tvrtek 20. zá?í 2018 19:16:04 UTC+2 Rich napsal(a):
How do you have your loadmodule for rivet configured in Apache?

Looking at the Apache install where I have a copy of Rivet running, the
string given to "IfModule" needs to be the same as the name below:

LoadModule rivet_module /usr/lib64/httpd/modules/mod_rivet.so
^^^^^^^^^^^^

Maybe you have "rivet_module.c" there, if so, that's why .c worked,
although that is a different way of naming the modules.

Rich

unread,
Sep 20, 2018, 1:36:27 PM9/20/18
to
P8j6 <jureck...@gmail.com> wrote:
> Dne ?tvrtek 20. zá?í 2018 18:15:50 UTC+2 Rich napsal(a):
>> > Dne ?tvrtek 20. zá?í 2018 17:31:37 UTC+2 Rich napsal(a):
>> >> > Hi,
>> >> >
>> >> > how can i configure rivet 3.0 to work with utf-8 characters in tcl files?
>> >> >
>> >> > On server, I have this simple page: test.tcl, saved with utf-8 encoding
>> >> >
>> >> > puts {
>> >> > <!DOCTYPE html>
>> >> > <html lang="cs">
>> >> > ...
>> >> > And yet, in browser, if i visit: http://127.0.0.1/test.tcl
>> >> > The text "Zku?ební ?et?zec" comes garbled.
>> >>
>> >> What happens, if you add this line at the start of your 'test.tcl'
>> >> file?:
>> >>
>> >> fconfigure stdout -encoding utf-8
>> >
>> > Nothing. Text remain garbled.
>> >
>> > I think, stdout channel should be utf-8 configured before test.tcl is
>> > loaded by server. But i dont know where to put it.
>> >
>> > I also tried put it into the BeforeScript directive:
>> >
>> > RivetServerConf BeforeScript "fconfigure stdout -encoding utf-8"
>> >
>> > But it doesn't help either.
>>
>> This suggests then that somewhere within the remainder of the channel
>> between Tcl and the ultimate browser that there is an encoding setting
>> that is not yet set correctly.
>>
>> What http headers does your server offer up when you browse to it?
>
>
> These are headers from Firefox, when i visit my test.tcl page:
> ...
> RESPONSE:
> ...
> Content-Type: text/html;charset=utf-8

Ok, so the utf-8 string ends up in the HTTP headers. After you've
loaded the page, what does Firefox's "page info" pane say about the
character set Firefox actually used?

Also, do you have Firefox configured to use a font that has glyphs for
the utf-8 codepoints are are using?

P8j6

unread,
Sep 20, 2018, 2:05:30 PM9/20/18
to
Dne čtvrtek 20. září 2018 19:36:27 UTC+2 Rich napsal(a):
Ok, i think i found solution. Not sure if ideal, but it works :)

I added this directive to rivet configuration:

RivetServerConf BeforeScript "encoding system utf-8"

Now tcl in rivet sourcing and returning all files correctly.

Anyway, thanks for your time and help!

Georgios Petasis

unread,
Oct 8, 2018, 5:32:15 AM10/8/18
to
What I usually do, is to define an "init" script, which all other
scripts get sourced, with "source -encoding utf-8".
And then, just before returning the response, use "fconfigure stdout
-encoding utf-8".

And I do not touch the system encoding (as recommended).
But I have tested only under Fedora & Ubuntu.

(The fact that it works by changing the whole system encoding, suggests
that the problem may be while reading your source files...)

George
0 new messages