Sujet : Re: Problem with locale
De : hruodr (at) *nospam* gmail.com (Roderick)
Groupes : comp.lang.tclDate : 20. Jan 2025, 19:18:34
Autres entêtes
Organisation : MB-NET.NET for Open-News-Network e.V.
Message-ID : <7d2a76de-b543-c84b-30e1-2db54f9803aa@gmail.com>
References : 1
The following solves the problem:
1) Begin the script with
#!/bin/sh
exec tclsh -encoding utf-8 "$0" ${1+"$@"}
2) Put in the script the command
encoding system utf-8
-- I would preffer#!/usr/opt/bin/tclsh -encoding utf-8But FreeBSD seems not to allow it.RodOn Mon, 20 Jan 2025, Roderick wrote:
>
I am having problems with a cgi script, it does not represent correctly
the UTF-8 strings of a sqlitedb.
>
Is there a way to change the locale from inside a script?
>
I wrote the following testig script:
>
---
#!/usr/opt/bin/tclsh
puts "Content-Type: text/text; charset=utf-8\r\n\r"
puts AOU=äöü
puts stdout=[fconfigure stdout -encoding]
puts system=[encoding system]
puts $env(LC_ALL)
----
>
If I run it on a shel I get:
>
----
Content-Type: text/text; charset=utf-8
>
AOU=äöü
stdout=utf-8
system=utf-8
en_US.UTF-8
-----
>
If I run it through CGI I get in the browser:
>
----
AOU=äöü
stdout=iso8859-1
system=iso8859-1
---
>
We see:
>
1) the variable $env(LC_ALL) is not set in CGI.
2) although everywhere the encoding is iso8859-1,
it does understand the UTF-8 of the script (AOU=äöü)!!!!!
>
I am really confused, any hint?
>
Thanks a lot
Rod.
>