[Mono-list] SOLVED: Test ASPX: mod-mono-server2 renders utf-8 encodings as question marks, xsp2 and mod-mono-server OK
Alex Villacís Lasso
avillaci at ceibo.fiec.espol.edu.ec
Mon May 19 12:54:41 EDT 2008
Alex Villacís Lasso escribió:
> Using Fedora Core 8 with Mono repository from opensuse.org for Fedora 8.
>
> Maybe this has been answered before, but could not find any references.
>
> I have this problem with the test ASPX file attached, with the
> Web.config file. The ASPX file has non-ASCII characters (utf-8
> encoded) as part of the HTML content in the file. When I serve this
> file with mod-mono-server or with xsp2, the characters are displayed
> correctly. If, however, I try to serve it with mod-mono-server2, the
> characters corresponding to the utf-8 encoding are rendered as
> question marks. I have checked with telnet that the server does
> specify utf-8 as encoding:
>
> [alex at srv64 public_html]$ telnet localhost 80
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> GET /~alex/TestODBC.aspx HTTP/1.1
> Host: localhost
> Connection: close
>
> HTTP/1.1 200 OK
> Date: Sat, 17 May 2008 16:34:36 GMT
> Server: Apache/2.2.8 (Fedora)
> Content-Length: 2143
> Cache-Control: private
> Set-Cookie: ASP.NET_SessionId=011364A41760ECF8497F5AC2; path=/~alex
> Connection: close
> Content-Type: text/html; charset=utf-8
>
> However, the response itself shows question marks instead of the bytes
> corresponding to the proper encoding:
>
> <span id="lblPeticion">Petici??n SQL:</span></td>
>
> This should read "Petición" with an accented letter o .
>
> If I had to guess, I would say that the encoding gets garbled by a
> superfluous conversion to ASCIIEncoding after being generated
> correctly as UTF-8.
>
> Could any of you please confirm whether this happens to you?
Responding to myself, this problem is actually a configuration issue. I
found the solution while fixing some bugs I found in mod_mono 1.9 and
xsp 1.9 which apparently also exist in current RPMs from OpenSUSE. This
deserves an entry in the FAQ for ASP.NET in www.go-mono.com, since it
will bite anyone who tries to use Fedora 8 in the default configuration.
The server mod-mono-server2 honors the LANG environment variable when
displaying response output. Normally this is a good thing. However, the
apache installation in Fedora 8 runs with a standard locale of LANG=C
(unless overriden in /etc/sysconfig/httpd), which gets inherited by
auto-spawn by mod_mono into mod-mono-server2. This is true even when the
system uses a different locale (such as my es_EC.UTF-8). So when
deploying an ASPX page that ouputs non-ASCII characters to an Apache
directory via mod-mono-server2, it will use the C locale instead of the
UTF-8 locale of choice, resulting in question marks for non-ASCII
encodings.
The solution is to make mod-mono-server2 see a LANG environment variable
that is consistent with the rest of the system. The way I used is to
change the setting in /etc/sysconfig/httpd HTTPD_LANG and set it to
es_EC.UTF-8. Hope this helps others in the same situation as me.
--
perl -e '$x=2.4;print sprintf("%.0f + %.0f = %.0f\n",$x,$x,$x+$x);'
More information about the Mono-list
mailing list