Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Problem z kodowaniem APACHE
Forum PHP.pl > Forum > Serwery WWW > Apache
pc-et100
mam problem z kodowaniem a dokładnie chodzi o to ze przy uruchamianiu stroni pod IE wszystko wyświetla się prawie dobrze - prawie- bo nie czyta mi niektórych polskich znakó jak np ź, ś wyskakują zamiast niech jakieś krzaczki, natomiast gdy uruchamiam stronke pod mozilla to nawet nie chce załadowac tła stronki zawarte w pliku a nazwie tło.gif. Nie jest to na pewno wina kodu w html bo jak uruchamiam stronke z katalogu (nie z serwera) wszystko działa ok. Oto frgment pliku httdp.conf dotyczący mojej konfiguracji:

# DefaultLanguage and AddLanguage allows you to specify the language of
# a document. You can then use content negotiation to give a browser a
# file in a language the user can understand.
#
# Specify a default language. This means that all data
# going out without a specific language tag (see below) will
# be marked with this one. You probably do NOT want to set
# this unless you are sure it is correct for all cases.
#
# * It is generally better to not mark a page as
# * being a certain language than marking it with the wrong
# * language!
#
DefaultLanguage pl
#
# Note 1: The suffix does not have to be the same as the language
# keyword --- those with documents in Polish (whose net-standard
# language code is pl) may wish to use "AddLanguage pl .po" to
# avoid the ambiguity with the common suffix for perl scripts.
#
# Note 2: The example entries below illustrate that in some cases
# the two character 'Language' abbreviation is not identical to
# the two character 'Country' code for its country,
# E.g. 'Danmark/dk' versus 'Danish/da'.
#
# Note 3: In the case of 'ltz' we violate the RFC by using a three char
# specifier. There is 'work in progress' to fix this and get
# the reference data for rfc1766 cleaned up.
#
# Catalan (ca) - Croatian (hr) - Czech (cs) - Danish (da) - Dutch (nl)
# English (en) - Esperanto (eo) - Estonian (et) - French (fr) - German

(de)
# Greek-Modern (el) - Hebrew (he) - Italian (it) - Japanese (ja)
# Korean (ko) - Luxembourgeois* (ltz) - Norwegian Nynorsk (nn)
# Norwegian (no) - Polish (pl) - Portugese (pt)
# Brazilian Portuguese (pt-BR) - Russian (ru) - Swedish (sv)
# Simplified Chinese (zh-CN) - Spanish (es) - Traditional Chinese (zh-TW)
#
AddLanguage ca .ca
AddLanguage cs .cz .cs
AddLanguage da .dk
AddLanguage de .de
AddLanguage el .el
AddLanguage en .en
AddLanguage eo .eo
AddLanguage es .es
AddLanguage et .et
AddLanguage fr .fr
AddLanguage he .he
AddLanguage hr .hr
AddLanguage it .it
AddLanguage ja .ja
AddLanguage ko .ko
AddLanguage ltz .ltz
AddLanguage nl .nl
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pl .po
AddLanguage pt .pt
AddLanguage pt-BR .pt-br
AddLanguage ru .ru
AddLanguage sv .sv
AddLanguage zh-CN .zh-cn
AddLanguage zh-TW .zh-tw

#
# LanguagePriority allows you to give precedence to some languages
# in case of a tie during content negotiation.
#
# Just list the languages in decreasing order of preference. We have
# more or less alphabetized them here. You probably want to change this.
#
LanguagePriority pl ca cs da de el eo es et fr he hr it ja ko ltz nl nn

no en pt pt-BR ru sv zh-CN zh-TW

#
# ForceLanguagePriority allows you to serve a result page rather than
# MULTIPLE CHOICES (Prefer) [in case of a tie] or NOT ACCEPTABLE

(Fallback)
# [in case no accepted languages matched the available variants]
#
ForceLanguagePriority Prefer Fallback

#
# Specify a default charset for all pages sent out. This is
# always a good idea and opens the door for future internationalisation
# of your web site, should you ever want it. Specifying it as
# a default does little harm; as the standard dictates that a page
# is in iso-8859-1 (latin1) unless specified otherwise i.e. you
# are merely stating the obvious. There are also some security
# reasons in browsers, related to javascript and URL parsing
# which encourage you to always set a default char set.
#
AddDefaultCharset off

#
# Commonly used filename extensions to character sets. You probably
# want to avoid clashes with the language extensions, unless you
# are good at carefully testing your setup after each change.
# See http://www.iana.org/assignments/character-sets for the
# official list of charset names and their respective RFCs.
#

AddCharset ISO-8859-1 .iso8859-1 .latin1
AddCharset ISO-8859-2 .iso8859-2 .iso-pl
AddCharset ISO-8859-3 .iso8859-3 .latin3
AddCharset ISO-8859-4 .iso8859-4 .latin4
AddCharset ISO-8859-5 .iso8859-5 .latin5 .cyr .iso-ru
AddCharset ISO-8859-6 .iso8859-6 .latin6 .arb
AddCharset ISO-8859-7 .iso8859-7 .latin7 .grk
AddCharset ISO-8859-8 .iso8859-8 .latin8 .heb
AddCharset ISO-8859-9 .iso8859-9 .latin9 .trk
AddCharset ISO-2022-JP .iso2022-jp .jis
AddCharset ISO-2022-KR .iso2022-kr .kis
AddCharset ISO-2022-CN .iso2022-cn .cis
AddCharset Big5 .Big5 .big5
# For russian, more than one charset is used (depends on client, mostly):
AddCharset WINDOWS-1251 .cp-1251 .win-1251
AddCharset CP866 .cp866
AddCharset KOI8-r .koi8-r .koi8-ru
AddCharset KOI8-ru .koi8-uk .ua
AddCharset ISO-10646-UCS-2 .ucs2
AddCharset ISO-10646-UCS-4 .ucs4
AddCharset UTF-8 .utf8

# The set below does not map to a specific (iso) standard
# but works on a fairly wide range of browsers. Note that
# capitalization actually matters (it should not, but it
# does for some browsers).
#
# See http://www.iana.org/assignments/character-sets
# for a list of sorts. But browsers support few.
#
AddCharset GB2312 .gb2312 .gb
AddCharset utf-7 .utf7
AddCharset utf-8 .utf8
AddCharset big5 .big5 .b5
AddCharset EUC-TW .euc-tw
AddCharset EUC-JP .euc-jp
AddCharset EUC-KR .euc-kr
AddCharset shift_jis .sjis

Prosze o pomoc w miare możliwości lub o linka gdzie został już rozwiązany taki problem
escaflowne
Fragment pliku konfiguracyjnego Apache'a, który podałeś nie ma tutaj nic do rzeczy. Te dyrektywy przydają się wtedy, kiedy masz stronę w wielu językach (plik każdej wersji językowej ma odpowiednie rozszerzenie, np. index.html.en lub index.html.pl) i serwer WWW ma na podstawie nagłówków wysłanych przez przeglądarkę klienta ustalić, którą wersję językową pliku ma mu zapodać (manual do apache'a jest zrobiony w taki właśnie sposób).
Pierwszy pomysł jaki przyszedł mi do głowy po rozpoczęciu czytania twojego posta: a kodowanie w meta-tagach podałeś prawidowe? Plik został zapisany w odpowiednim kodowaniu?
Fo
właśnie że ten fragment httpd.conf mówi i to bardzo dużo :

AddDefaultCharset off

:?:

powinno być tak :

AddDefaultCharset ISO-8859-2

czyli defaultowe kodowanie dla apache na język polski.

pzdr.
pc-et100
a więc tak co do wypowiedzi escaflowne to mam w każdym pliku w <HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
i to nie pomaga, a przecież AddDefaultCharset oznacza dobyślne kodowanie więc jeśli juz w pliku html umieszczam kodowanie w iso-8859-2 to po co się powtażać w httdp.conf, ale postanowiłem wypróbować tak jak mi napisałeś FO i taki sam efekt jak poprzednio explorer wyświetla OK ale nie do konca (krzaczki w linkach), mozilla zupełnie sobie nie radzi z tym
zuczek
A może brakuje w stronce:
dla html 4.01
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">

i
  1. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">

lub
dla xhtml 1.0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">

i
  1. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
pc-et100
a co do zapisywania plików to zapisane są za pomoca kodowania ANSI, czy tak powinno być ?
escaflowne
Szybka próba: czy jeżeli zadeklarujesz kodowanie windows-1250 (bądź tylko przełączysz kodowanie znaków w przeglądarce), to czy widzisz wszystkie polskie literki?
zenek3
28.01.2007
Witam! Mam podobny problem z apache 2.0

Gdy otwieram stronę - przeglądarka zupełnie lekceważy ustawienie kodowania w sekcji meta i zawsze wybiera takie kodowanie jakie ustawię w pliku konfiguracyjnym apache'a jako domyślne.
Jednak gdy wczytam stronę z dysku z pominięciem serwera wtedy przeglądarka wybiera kodowanie jak należy.
Nie bardzo wiem co mam zmienić w konfiguracji serwera aby wszystko grało..
Sprawdzałem to zarówno w firefoxie 2.0 jak i IE 6.

Cała ta "sekcja językowa" w httpd.conf wygląda tak:

Kod
# Simplified Chinese (zh-CN) - Spanish (es) - Traditional Chinese (zh-TW)
#
AddLanguage ca .ca
AddLanguage cs .cz .cs
AddLanguage da .dk
AddLanguage de .de
AddLanguage el .el
AddLanguage en .en
AddLanguage eo .eo
AddLanguage es .es
AddLanguage et .et
AddLanguage fr .fr
AddLanguage he .he
AddLanguage hr .hr
AddLanguage it .it
AddLanguage ja .ja
AddLanguage ko .ko
AddLanguage ltz .ltz
AddLanguage nl .nl
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pl .po
AddLanguage pt .pt
AddLanguage pt-BR .pt-br
AddLanguage ru .ru
AddLanguage sv .sv
AddLanguage zh-CN .zh-cn
AddLanguage zh-TW .zh-tw

#
# LanguagePriority allows you to give precedence to some languages
# in case of a tie during content negotiation.
#
# Just list the languages in decreasing order of preference. We have
# more or less alphabetized them here. You probably want to change this.
#
LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW

#
# ForceLanguagePriority allows you to serve a result page rather than
# MULTIPLE CHOICES (Prefer) [in case of a tie] or NOT ACCEPTABLE (Fallback)
# [in case no accepted languages matched the available variants]
#
ForceLanguagePriority Prefer Fallback

#
# Specify a default charset for all pages sent out. This is
# always a good idea and opens the door for future internationalisation
# of your web site, should you ever want it. Specifying it as
# a default does little harm; as the standard dictates that a page
# is in iso-8859-1 (latin1) unless specified otherwise i.e. you
# are merely stating the obvious. There are also some security
# reasons in browsers, related to javascript and URL parsing
# which encourage you to always set a default char set.
#
AddDefaultCharset ISO-8859-2

#
# Commonly used filename extensions to character sets. You probably
# want to avoid clashes with the language extensions, unless you
# are good at carefully testing your setup after each change.
# See http://www.iana.org/assignments/character-sets for the
# official list of charset names and their respective RFCs.
#
AddCharset ISO-8859-1  .iso8859-1 .latin1
AddCharset ISO-8859-2  .iso8859-2 .latin2 .cen
AddCharset ISO-8859-3  .iso8859-3 .latin3
AddCharset ISO-8859-4  .iso8859-4 .latin4
AddCharset ISO-8859-5  .iso8859-5 .latin5 .cyr .iso-ru
AddCharset ISO-8859-6  .iso8859-6 .latin6 .arb
AddCharset ISO-8859-7  .iso8859-7 .latin7 .grk
AddCharset ISO-8859-8  .iso8859-8 .latin8 .heb
AddCharset ISO-8859-9  .iso8859-9 .latin9 .trk
AddCharset ISO-2022-JP .iso2022-jp .jis
AddCharset ISO-2022-KR .iso2022-kr .kis
AddCharset ISO-2022-CN .iso2022-cn .cis
AddCharset Big5        .Big5       .big5
AddCharset WINDOWS-1250 .cp-1250   .win-1250

# For russian, more than one charset is used (depends on client, mostly):
AddCharset WINDOWS-1251 .cp-1251   .win-1251
AddCharset CP866       .cp866
AddCharset KOI8-r      .koi8-r .koi8-ru
AddCharset KOI8-ru     .koi8-uk .ua
AddCharset ISO-10646-UCS-2 .ucs2
AddCharset ISO-10646-UCS-4 .ucs4
AddCharset UTF-8       .utf8

# The set below does not map to a specific (iso) standard
# but works on a fairly wide range of browsers. Note that
# capitalization actually matters (it should not, but it
# does for some browsers).
#
# See http://www.iana.org/assignments/character-sets
# for a list of sorts. But browsers support few.
#
AddCharset GB2312      .gb2312 .gb
AddCharset utf-7       .utf7
AddCharset utf-8       .utf8
AddCharset big5        .big5 .b5
AddCharset EUC-TW      .euc-tw
AddCharset EUC-JP      .euc-jp
AddCharset EUC-KR      .euc-kr
AddCharset shift_jis   .sjis

#
# AddType allows you to add to or override the MIME configuration


Natomiast kod strony tak:

Kod
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta  http-equiv="content-language" content="pl" />
<title>ąąććżźć</title>

</head>

<body>
ąąćććźźżżżńńóółł
</body>

</html>


Firefox oraz IE w powyższym przykładzie wybierają kodowanie iso-8859-2 - czyli takie jak mam ustawione jako domyślne w httpd.conf i wychodzą krzaki..

29.01.2007
OK. Ustawiłem AddDefaultCharset na Off i wszystko działa jak należy. Ale czy to jest rozwiązanie? W configu pisze, że zaleca się ustawić tę opcję na jakąś konkretną wartość np. iso-8859-2. Na chłopski rozum domyślne kodowanie powinno "wskoczyć" tylko w wypadku braku deklaracji w sekcji meta dokumentu html.. Jednak wskakuje zawsze.
kodex_
W przypadku braku wpisu
Kod
AddDefaultCharset OFF

w httpd.conf lub apache2.conf lub w przypadku (sic) 'zahashowania' tego wpisu (tak jak defaultowo w debianie 4.0) pojawiają się krzaki.
Wystarczy dodać wpis i strony kodowe zaczynają się wyświetlać poprawnie w większości przyopadków.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.