やじゅ@アプリケーション・ラボ わんくま支局

目次

Blog 利用状況

ニュース

プロフィール

MSMVP

「あいうえお」が「BDFHJ」に文字化けする理由

先日、GAE上のPHPを動作する上で、echo “あいうえお”が “BDFHJ”に文字化けして表示されました。
文字化けするのは文字コードが一致していない部分があるからなのですが、どうしてこのような英文字に変換されてしまうのか疑問に思ったわけです。
ブラウザのエンコードにあるUnicode(UTF-8)、日本語(シフトJIS)、日本語(EUC)、西ヨーロッパ言語(Windows)のいずれかでもない。

ネット上で「あいうえお BDFHJ」で検索するとそこそこヒットしたりします。

■調べてみた結果:
GAE上のPHPを動作させる「Quercus(クァーカス(クエルクス):ラテン語で「樫の木」の意味)」は、Javaで動作しています。Javaの文字列の内部コードはUnicode(UTF-16)となっております。(ちなみに.NETも文字列の内部コードもUnicode(UTF-16)ですね)

つまり、UTF-8で文字コードを設定しても、Javaの文字列内部コード上はUnicode(UTF-16)に変換されてしまうわけです。

JIS

SJIS

EUC

UTF-8

UTF-16

04 01 2421 829F A4A1 E38181 3041
04 02 2422 82A0 A4A2 E38182 3042
04 03 2423 82A1 A4A3 E38183 3043
04 04 2424 82A2 A4A4 E38184 3044
04 05 2425 82A3 A4A5 E38185 3045
04 06 2426 82A4 A4A6 E38186 3046
04 07 2427 82A5 A4A7 E38187 3047
04 08 2428 82A6 A4A8 E38188 3048
04 09 2429 82A7 A4A9 E38189 3049
04 10 242A 82A8 A4AA E3818A 304A

Quercusは、既存のPHPアプリを動作させることを優先して文字セットはISO-8859-1(Latin-1)を前提としているようです。
http://www.atmarkit.co.jp/fjava/column/koyama/koyama05_2.html

コンピュータは主にアメリカで発達してきたため、未だにアルファベットや数字などの1バイトを基本単位として扱う前提で作られており、日本語のように多くの文字を必要とする言語は、1文字を表わすのに2バイト以上を使います。

今回の文字化けの現象(あいうえお→BDFHJ)を見る限りは、2バイトではなく1バイトとして扱われてしまったことにあります。

あいうえお の文字コードと BDFHJ の文字コードを比較してみると、上位バイトの30が00と違っていても下位バイトは一致しています。
あいうえお 3042 3044 3046 3048 304A
BDFHJ 0042 0044 0046 0048 004A

それで、UTF-16からISO-8859-1の1バイト単位に変換されたならば上位バイトの30(文字:0)も変換されて、あいうえお→0B0D0F0H0J になるのでは? と思ったわけです。
そんなことを通勤途中の車の運転中に考えていたら、ふと思いついたんですよね。

「あいうえお」ではなく、echo “BDFHJ”と表示するようにしたとすると、文字列の内部コード上のUTF-16では00を上位バイトに付加したコード(例 B=0042)となります。
これを逆にUTF-16からISO-8859-1の1バイト単位に変換するとしたら、上位バイトは無視して下位バイトだけ取得すればいいわけです。
つまり、「あいうえお→BDFHJ」になるのは、UTF-16に変換後に下位バイトだけ取得して表示しているためです。
(実際は、下位バイトだけ取得後に所定の文字コード(例 UTF-8)に再変換されているはずです。今回は再変換されても表示が変わらなかった)
http://jfriends.javaopen.org/mlarchive_3/msg00135.html


ちなみに、Quercus3.1.6では上記の文字化けしなかったのですが、Quercus4.0以降では文字化けするようになってしまいます。
そんな対処法は下記サイトが参考になります。もっといい方法があるかも知れませんけどね。

QuercusでJavaからの日本語入力を取得して動作させる。
http://poepoemix.blogspot.com/2011/05/quercusjava.html

投稿日時 : 2011年9月9日 2:57

コメントを追加

# Born Into Darkness - New HOG Adventure - Wendy99 Version Download 2021/12/13 7:41 ClarkEdget

https://wakelet.com/wake/9HFKxPG9ZGt9MUShb9BEo
https://wakelet.com/wake/lZKX2eGsz0UEqe_XFsw7E
https://wakelet.com/wake/AZ0KYBlgdwOnHfmOSROZ-
https://wakelet.com/wake/MhHG2o_Y7DJRn133Z6a4J
https://wakelet.com/wake/SOKYQyD3Sn-ylUKT-fP9r
https://wakelet.com/wake/HhYLRhWCWogJus2WWoYGz
https://wakelet.com/wake/mreZVKKPeQ4FGfY_w46ET
https://wakelet.com/wake/t5VpbyAhk9W-ye9r5Lhnc
https://wakelet.com/wake/hfYR6hN8mV0Wf-8aDUsTw
https://wakelet.com/wake/OJthLu0vnb-0MHH4E_8fk
https://wakelet.com/wake/5TYzQBXC47vFtbRShJmTv
https://wakelet.com/wake/7hU6_Wciw5W6jLweptaLI
https://wakelet.com/wake/0jCPq7aM_vD8xso7XI5om
https://wakelet.com/wake/DFmmT3m4Soz6QroFRP-tC
https://wakelet.com/wake/7JA0l1JAfY-u-gdoe_kyZ
https://wakelet.com/wake/5rqw4Df3f3u8NwThHcEpc
https://wakelet.com/wake/x9AUW3QvSRk7StwmGnx6l
https://wakelet.com/wake/-9sPSF0Gqk5b57i5pCO5h
https://wakelet.com/wake/w1lQoGyj9oyzTves3fl2i
https://wakelet.com/wake/UV3IryVNROfN6ayzjJKsw

# xforce keygen 32-bit AutoCAD LT 2019 2021/12/13 15:54 ClarkEdget

https://wakelet.com/wake/zhFVSfAImXGOBskwAZyJ1
https://wakelet.com/wake/9ija2btkwkiY4SiZfqF4S
https://wakelet.com/wake/TRuP0_DsF8jHFP7R1olhP
https://wakelet.com/wake/JcMMcQ3IidbbOUDe1njAv
https://wakelet.com/wake/fotorXSX3RwD0hU7MFN8U
https://wakelet.com/wake/2ydzkVEvib4qu4VQ6W-aX
https://wakelet.com/wake/R-S7edtimTb2kL1-bN4fE
https://wakelet.com/wake/p0NVSBn5yyYA3c8X6IIOY
https://wakelet.com/wake/W61EST-uGCGDo-8sj6xhg
https://wakelet.com/wake/gFJIKrDPUBgopQq9PNIa3
https://wakelet.com/wake/orSpMjw6t1XxJfHTxgbmK
https://wakelet.com/wake/yGdsSqJrFpumW-Sbe2acc
https://wakelet.com/wake/9q2jg1CZILxWUUi6kYCIO
https://wakelet.com/wake/W0jt1eVLmh1M4ekXrAy0V
https://wakelet.com/wake/7D7AdvTZGU4BvST4OBdcF
https://wakelet.com/wake/IkRHvxgq9xqg_GNepseqB
https://wakelet.com/wake/FiwBAFv3xPWan8k5AKCsS
https://wakelet.com/wake/R60YkgIdUWK5sRe2U-w_a
https://wakelet.com/wake/SbAckR-9GeAnyZcxe3NPB
https://wakelet.com/wake/FrVQ1kSfYUGvnmBewv4xi

# LS Island-Land-Midsummer-Touch-Hots, etc LS [9 Sets] 2021/12/14 0:15 ClarkEdget

https://trello.com/c/Kwh26ene/16-the-great-gatsby-movie-free-download-in-hindi-720p-download
https://trello.com/c/U393PO97/15-microelectronics-circuit-analysis-and-design-4th-edition-pdf-downloadl
https://trello.com/c/ZEZAa0sM/28-irender-nxt-5-sketchup-license-key
https://trello.com/c/wC8b2SlX/34-cabinet-vision-solid-8-crack
https://trello.com/c/mWD1h07Q/36-make-the-girl-dance-baby-baby-baby-uncensored
https://trello.com/c/9kZWnX7v/9-windows-7-64-bit-keygen-ultimate-warrior
https://trello.com/c/KRU5p7S4/55-neje-laser-engraver-software-24-8
https://trello.com/c/dPNMf1td/10-matchmover-land-desktop-companion-2019-crack-64
https://trello.com/c/UPEYKJNG/27-dolbyadvancedaudiov2driverfreedownloadwindows718
https://trello.com/c/Sf3DJX78/8-torrent-mercedes-comand-aps-europe-20142015-ntg4-v12-714
https://trello.com/c/vOtI3498/10-rab-ne-bana-di-jodi-full-movie-1080p-download-utorrent
https://trello.com/c/XUEZbqwA/19-vector-magic-desktop-edition-1-14-portable
https://trello.com/c/XJXzB7OQ/34-topaz-vivacity-crack-serial-keyl
https://trello.com/c/dHZu51k8/21-windows-10-all-editions-activator-one-click-activation
https://trello.com/c/sKiqNcI9/42-silkypix-developer-studio-pro-9e-v9060-crack-mac-osx
https://trello.com/c/Os86vJLm/29-delta-horizon-torrent-download-pc
https://trello.com/c/mI2ApQ12/19-nfs-underground-2-mod-city-drift-world-edition-v2-0-up-by-need4speedunderground2-blogspot-com-rar
https://trello.com/c/h72Kq1ag/23-synology-surveillance-station-license-keygen-generator
https://trello.com/c/UOcrkhCK/37-ping-pong-neu-1-lehrerhandbuch-pdf-full
https://trello.com/c/aTbHMveN/27-the-hello-dual-audio-720p-download-torrent

# ivermectin 5 http://stromectolabc.com/
ivermectin lotion cost 2022/02/08 16:42 Busjdhj

ivermectin 5 http://stromectolabc.com/
ivermectin lotion cost

# Свежие новости 2022/02/16 5:41 Adamwkb

Где Вы ищите свежие новости?
Лично я читаю и доверяю газете https://www.ukr.net/.
Это единственный источник свежих и независимых новостей.
Рекомендую и Вам

# doxycycline 100mg https://doxycyline1st.com/
vibramycin 100 mg 2022/02/26 8:28 Doxycycline

doxycycline 100mg https://doxycyline1st.com/
vibramycin 100 mg

# I am regular reader, how are yyou everybody? This paragraph posted at this website is in fact fastidious. 2022/05/14 22:49 Iam regular reader, how are you everybody? This pa

I am regular reader, how are you everybody? This paragraph posted at this website is in fact fastidious.

# I am regular reader, how are yyou everybody? This paragraph posted at this website is in fact fastidious. 2022/05/14 22:50 Iam regular reader, how are you everybody? This pa

I am regular reader, how are you everybody? This paragraph posted at this website is in fact fastidious.

# I am regular reader, how are yyou everybody? This paragraph posted at this website is in fact fastidious. 2022/05/14 22:52 Iam regular reader, how are you everybody? This pa

I am regular reader, how are you everybody? This paragraph posted at this website is in fact fastidious.

# ロレックス 値段 cd 2022/08/31 8:05 dqvwgos@ocn.ne.jp

注文してから直ぐにメールを頂きとても丁寧な対応をして頂きました。
梱包もきれいにされておりお礼のお手紙まで添えられて、購入する側としては
とても気持ち良くお買い物ができました。
信頼のおけるショップです。
又機会がありましたら是非利用させて頂きます。
ロレックス 値段 cd https://www.kopijp.com/product/detail.aspx-id=10619

# The O-1 nonimmigrant visa classification includes individuals who either: (1) Have ``extraordinary ability'' within the sciences, arts, education, business or athletics, as demonstrated by sustained national or international acclaim; or (2) have a. 2022/09/19 13:55 The O-1 nonimmigrant visa classification includes

The O-1 nonimmigrant visa classification includes individuals who either: (1) Have
``extraordinary ability'' within the sciences, arts, education, business or athletics, as demonstrated
by sustained national or international acclaim;
or (2) have a.

# sildenafil without a doctor's prescription https://pillswithoutprescription.xyz/
non prescription erection pills 2022/10/01 19:37 CanadaPharm

sildenafil without a doctor's prescription https://pillswithoutprescription.xyz/
non prescription erection pills

# buying ed pills online https://erectiledysfunctionpills.shop/ 2022/10/14 22:50 Erectile

buying ed pills online https://erectiledysfunctionpills.shop/

# best dating https://datingtopreview.com/
dates online for money 2022/10/17 20:39 Dating

best dating https://datingtopreview.com/
dates online for money

# date internet site https://topdatingsites.fun/
meet women at zushi beach 2022/11/15 0:29 DatingTop

date internet site https://topdatingsites.fun/
meet women at zushi beach

# how can i get prednisone online without a prescription https://prednisone20mg.site/
purchase prednisone canada 2022/11/15 17:59 Prednisone

how can i get prednisone online without a prescription https://prednisone20mg.site/
purchase prednisone canada

# buy prednisone without prescription https://prednisonepills.site/
buy cheap prednisone 2022/11/28 23:54 Prednisone

buy prednisone without prescription https://prednisonepills.site/
buy cheap prednisone

# online single sites https://datingsiteonline.site/
meet older women for free 2022/12/05 23:51 Tading

online single sites https://datingsiteonline.site/
meet older women for free

# doctors prescribing hydroxychloroquine near me 2022/12/29 12:48 MorrisReaks

https://www.hydroxychloroquinex.com/# hydroxychloroquine canada

# buy cytotec over the counter - https://cytotecsale.pro/# 2023/04/28 23:33 Cytotec

buy cytotec over the counter - https://cytotecsale.pro/#

# canadian prescription drug store https://pillswithoutprescription.pro/# 2023/05/14 22:15 PillsPresc

canadian prescription drug store https://pillswithoutprescription.pro/#

# erectile dysfunction medications https://edpill.pro/# - erectile dysfunction medications 2023/06/27 10:19 EdPills

erectile dysfunction medications https://edpill.pro/# - erectile dysfunction medications

# online apotheke deutschland 2023/09/26 14:44 Williamreomo

http://onlineapotheke.tech/# online apotheke versandkostenfrei
online apotheke deutschland

# versandapotheke deutschland 2023/09/27 0:01 Williamreomo

https://onlineapotheke.tech/# online apotheke versandkostenfrei
versandapotheke

# п»їonline apotheke 2023/09/27 1:23 Williamreomo

http://onlineapotheke.tech/# versandapotheke
versandapotheke deutschland

# online apotheke preisvergleich 2023/09/27 4:42 Williamreomo

http://onlineapotheke.tech/# versandapotheke deutschland
internet apotheke

# gГјnstige online apotheke 2023/09/27 7:42 Williamreomo

https://onlineapotheke.tech/# versandapotheke
versandapotheke

# online apotheke gГјnstig 2023/09/27 8:27 Williamreomo

http://onlineapotheke.tech/# versandapotheke versandkostenfrei
versandapotheke deutschland

# п»їonline apotheke 2023/09/27 17:32 Terrywef

acheter sildenafil 100mg sans ordonnance

# farmacie on line spedizione gratuita 2023/09/27 18:22 Rickeyrof

acheter sildenafil 100mg sans ordonnance

# migliori farmacie online 2023 2023/09/27 19:59 Rickeyrof

acheter sildenafil 100mg sans ordonnance

# farmacia online miglior prezzo 2023/09/27 20:48 Rickeyrof

acheter sildenafil 100mg sans ordonnance

# canadian online rx 2023/10/15 23:59 Kiethamert

http://gabapentin.world/# buy gabapentin online

# prescription online canada 2023/10/16 19:55 Dannyhealm

drug information and news for professionals and consumers. http://mexicanpharmonline.com/# reputable mexican pharmacies online

# prescription canada 2023/10/16 22:01 Dannyhealm

The widest range of international brands under one roof. http://mexicanpharmonline.shop/# pharmacies in mexico that ship to usa

# online mexican pharmacies 2023/10/17 11:44 Dannyhealm

Best and news about drug. https://mexicanpharmonline.com/# mexico drug stores pharmacies

# buy prescription online 2023/10/17 17:24 Dannyhealm

Stellar service in every department. https://mexicanpharmonline.com/# reputable mexican pharmacies online

# how to buy prescriptions from canada safely 2023/10/17 23:04 Dannyhealm

They ensure global standards in every pill. http://mexicanpharmonline.com/# mexico drug stores pharmacies

# canada pharmacies online 2023/10/17 23:38 Dannyhealm

Love the seasonal health tips they offer. https://mexicanpharmonline.com/# mexican rx online

# mail order prescriptions from canada 2023/10/18 10:34 Dannyhealm

Their global reputation precedes them. https://mexicanpharmonline.shop/# reputable mexican pharmacies online

# top rated canadian pharmacies 2023/10/18 12:54 Dannyhealm

The one-stop solution for all international medication requirements. https://mexicanpharmonline.com/# pharmacies in mexico that ship to usa

# paxlovid generic https://paxlovid.bid/ paxlovid covid 2023/10/25 18:30 Paxlovid

paxlovid generic https://paxlovid.bid/ paxlovid covid

# pills for ed 2023/11/20 20:14 WilliamApomb

http://tadalafil.trade/# buy tadalafil 20mg price canada

# how to get prednisone tablets https://prednisone.bid/ how much is prednisone 10 mg 2023/12/27 6:56 Prednisone

how to get prednisone tablets https://prednisone.bid/ how much is prednisone 10 mg

# farmacie online autorizzate elenco 2024/01/16 8:12 Wendellglaks

https://avanafilitalia.online/# acquisto farmaci con ricetta

# farmacia online piГ№ conveniente 2024/01/16 22:15 Robertopramy

https://avanafilitalia.online/# farmaci senza ricetta elenco

# top farmacia online 2024/01/17 0:17 Wendellglaks

http://tadalafilitalia.pro/# farmacia online migliore

# tamoxifen headache 2024/01/20 17:18 Normantug

https://clomidpharm.shop/# how to buy cheap clomid

# how to get cheap clomid without insurance 2024/01/20 21:57 LarryVoP

Setting global standards in pharmaceutical care http://clomidpharm.shop/# where to get clomid without rx

# where buy generic clomid price 2024/01/21 13:10 LarryVoP

Always providing clarity and peace of mind http://prednisonepharm.store/# prednisone uk buy

# Pharmacie en ligne fiable 2024/01/29 3:34 JerryNef

http://pharmadoc.pro/# Pharmacie en ligne livraison 24h

# pharmacie ouverte 2024/01/29 10:12 JerryNef

https://pharmadoc.pro/# Acheter médicaments sans ordonnance sur internet

# ivermectin price 2024/01/29 17:49 Andrewamabs

https://clomiphene.icu/# can you get cheap clomid without insurance

# ivermectin 9mg 2024/01/31 1:33 Andrewamabs

https://clomiphene.icu/# rx clomid

# ivermectin 20 mg 2024/01/31 9:17 Andrewamabs

http://prednisonetablets.shop/# buy prednisone 20mg

# free dating online chat 2024/03/03 23:06 RodrigoGrany

https://abelladanger.online/# abella danger izle

# freedating 2024/03/08 3:52 HowardBox

free dating sites no fees: http://evaelfie.site/# eva elfie photo

# single dating sites 2024/03/10 14:25 HowardBox

dating wites: http://sweetiefox.pro/# sweetie fox new

# jogo de aposta online 2024/03/12 3:25 Robertcog

http://aviatormocambique.site/# como jogar aviator em mocambique

# melhor jogo de aposta 2024/03/14 8:37 BrianTop

http://jogodeaposta.fun/# melhor jogo de aposta para ganhar dinheiro

# gates of olympus demo turkce 2024/03/28 3:50 KeithNaf

https://gatesofolympus.auction/# gates of olympus demo oyna

# no prescription on line pharmacies 2024/04/16 10:34 HarveyBum

https://edpill.top/# cheapest ed pills

タイトル
名前
URL
コメント