トラックバックの文字化け対策
日本語の文字コードの関係でトラックバックの文字化けってのがいろいろな
ブログツールの開発者を悩ましているが、試行錯誤の結果WordPressでは、
以下のような対策を考えた。
トラックバック送信時
1.charsetパラメータの付加
日本語圏では、charsetをトラックバックPOSTのパラメータに付加する事が
デファクトとなっているようなので、送信する文字コードを指定する。
2.UTF-8での送信オプションの追加
exciteのブログなどではUTF-8以外の文字コードによるトラックバックを
受け付けてくれないので、送信時にUTF-8によるトラックバックを可能にする
オプションを追加
3.Bookmarkletによる投稿時の、ターゲットの文字コード自動判定
Bookmarkletによる投稿時には、一度トラックバックURLの自動取得を目的として
ターゲットのページを読み込むようにしているので、この際に文字コードを
判定して、その文字コードによってトラックバックを送信する。
トラックバック受信時
基本的には以下の2つの方法で受信したトラックバックの文字コードを判定する。
1.charsetパラメータによる文字コード判定
2.mb_detect_encoding関数による文字コード判定
但し、PHPではphp.iniや.htaccess等によりmbstringの設定の違いによって、
charsetパラメータを信用する事がかえって文字化けの原因となる事が
わかってきた。
というのは、設定によってはPHPの方で自動的にPOSTされた文字列の文字コードを
判定して、事前に文字コード変換されてしまうので、これにcharsetパラメータを
参照して文字コード変換すると2重に変換する事になって文字化けが発生してしまう。
特にphp.iniにて、
mbstring.http_input = auto
mbstring.encoding_translation = On
等となっている場合には、この状況となる。
よって、受信時に既に変換済みかどうかを判定する必要が出てくる。
mb_http_input("P")という関数呼び出しによって、POST文字列をどういうcharsetとして
判断して変換したかという事が拾えるので、これらとphp.iniの設定内容を元に、
自動変換するかcharsetパラメータによる変換をするかを判定する事とした。
コメント
TrackBack URL : http://www.kowa.org/modules/wordpress/archives/2004/06/20/224/trackback/
コメントの投稿
改行や段落は自動です
URLとメールアドレスは自動的にリンクされますので、<a>タグは不要です。
以下のHTMLタグが使用可能です。<a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <br> <code> <em> <i> <strike> <strong>






日記更新
きこえる
Comment by のぶのぶ — 2004年7月25日(日) @ 10時39分07秒
テスト
http://www.kowa.org/modules/wordpress/archives/2004/06/20/224/
テストです。
Trackback by M's_Bar — 2005年6月14日(火) @ 22時16分20秒
この文字化け対策はありがたいです。
Comment by 人材派遣労働者 — 2008年2月17日(日) @ 15時24分55秒
htaccessで設定できることを初めて知りました。
Comment by 会社設立したばかり — 2008年6月18日(水) @ 10時07分40秒
ckbV6d Great topic, nice message. Thank you.,
Comment by Frank Rasmussen — 2009年7月9日(木) @ 22時19分58秒
JvNWoQ cool, i will bookmark it,
Comment by Rick Chiu — 2009年7月11日(土) @ 00時11分43秒
thank you this topic,
Comment by Francis Acosta — 2009年7月11日(土) @ 00時14分46秒
thank you this topic,
Comment by Francis Acosta — 2009年7月11日(土) @ 00時15分23秒
Thank you for this site, such as multi information.I! Thank you!,
Comment by nomad — 2009年7月11日(土) @ 00時14分03秒
great site. I love online games,
Comment by kevin parshall — 2009年7月11日(土) @ 00時16分05秒
YNxmID what gives you that idea?,
Comment by Jenny Nadler — 2009年7月11日(土) @ 18時07分27秒
YNxmID what gives you that idea?,
Comment by Jenny Nadler — 2009年7月11日(土) @ 18時06分52秒
what gives you that idea?,
Comment by jeanette jepson — 2009年7月11日(土) @ 18時08分09秒
Bravo! Nice Article.,
Comment by skip guthrie — 2009年7月11日(土) @ 18時08分45秒
Very interesting!I壇 like to see how far he goes and how well the word will get out.,
Comment by Grover Sonnier — 2009年7月11日(土) @ 18時09分55秒
Thank you! I liked the article! I love how you write beautifully.,
Comment by jamie hamner — 2009年7月11日(土) @ 18時09分20秒
Very interesting!I壇 like to see how far he goes and how well the word will get out.,
Comment by Grover Sonnier — 2009年7月11日(土) @ 18時10分21秒
Very interesting!I壇 like to see how far he goes and how well the word will get out.,
Comment by Grover Sonnier — 2009年7月11日(土) @ 18時10分56秒
wNxA1M I will go to you.,
Comment by Piseth Khun — 2009年7月14日(火) @ 06時58分47秒
thank you dear friend,
Comment by Ryan Gilbert — 2009年7月14日(火) @ 06時59分33秒
thank you dear friend,
Comment by Rita — 2009年7月14日(火) @ 07時02分49秒
Hey! I just searched for and I found your site!,
Comment by Tom Junius — 2009年7月14日(火) @ 07時02分11秒
what gives you that idea?,
Comment by VICTORIA MATTSON — 2009年7月14日(火) @ 07時03分27秒
Bravo! Nice Article.,
Comment by Danny Garmon — 2009年7月14日(火) @ 07時04分03秒
I think its good decision what he did.,
Comment by Chris Moffett — 2009年7月14日(火) @ 07時04分40秒
Hey! I just searched for and I found your site!,
Comment by DAWN VERNON — 2009年7月14日(火) @ 07時05分18秒
thanks for you.. nice good document!,
Comment by Alycia Harhai — 2009年7月14日(火) @ 07時06分31秒
nice job, very thanks?
Comment by Michael Pruckner — 2009年7月14日(火) @ 07時07分08秒
Thanks this design is very good..,
Comment by Kristen Sando — 2009年7月14日(火) @ 07時07分44秒
Cool Info, practical.. lol,
Comment by Alexandra Zeigler — 2009年7月14日(火) @ 07時08分19秒
GXeA3J Oh hell yeah no graphical smilies around here.,
Comment by lana rodriguez — 2009年7月14日(火) @ 14時21分52秒
GXeA3J Oh hell yeah no graphical smilies around here.,
Comment by lana rodriguez — 2009年7月14日(火) @ 14時22分28秒
Good Thank you It痴 very beautifully,
Comment by Barbara Pecor — 2009年7月14日(火) @ 14時23分13秒
sX7HZx Hey! I just searched for and I found your site!,
Comment by white black — 2009年7月14日(火) @ 14時23分43秒
Good Thank you It痴 very beautifully,
Comment by Bryan Dorynek — 2009年7月14日(火) @ 14時23分52秒
Very interesting!I壇 like to see how far he goes and how well the word will get out.,
Comment by Eileen Smith — 2009年7月14日(火) @ 14時24分29秒
Great work Thanks for your ideas.,
Comment by Matthew Walloch — 2009年7月14日(火) @ 14時25分17秒
Great work Thanks for your ideas.,
Comment by Matthew Walloch — 2009年7月14日(火) @ 14時25分53秒
cool, i will bookmark it,
Comment by Nichole Boyd — 2009年7月14日(火) @ 14時26分34秒
Thank you for this site, such as multi information.I! Thank you!,
Comment by lori moss — 2009年7月14日(火) @ 14時27分15秒
thanks for you.. nice good document!,
Comment by Jason Vetter — 2009年7月14日(火) @ 14時27分58秒
thanks for you.. nice good document!,
Comment by Jason Vetter — 2009年7月14日(火) @ 14時28分34秒
what gives you that idea?,
Comment by Victoria Marquez — 2009年7月21日(火) @ 12時33分17秒
Hi can someone please translate for me thanx,
Comment by Tiffany Buchanan — 2009年7月21日(火) @ 12時34分03秒
great site. I love online games,
Comment by Jess — 2009年7月21日(火) @ 12時34分48秒
nice job, very thanks
Comment by mikadiva — 2009年7月21日(火) @ 12時35分31秒