javaで作るwebアプリで扱う文字コード(日本語)について
javaで作るごく普通のwebアプリで扱う文字コード(日本語)についての質問です。
プレゼンテーション層-ビジネスロジック層の2層アーキテクチャで、データベースは
無く、ビジネスロジック層で入力ファイルを処理して結果を画面に出すというアプリです。
javaのデフォルト文字コードはUTF-8等だそうですが、例えばクライアントが
Linuxマシンの時は、入力テキストファイルは普通、EUC-JPと思います。
以下、2点質問です。
1.この時、EUC-JPのテキストからUTF-8への変換は、JVMが自動的にするのですか?
Yesだったら、クライアント側はプラットフォームの種類にかかわらず、
文字コードを意識する必要はないのでしょうか。
Noだったら、一般的にはどこがするのですか?
2.1の答えがどちらにしても、クライアントのOSのデフォルトのコードを
UTF-8に変更する必要は無いですよね?関連する他のアプリケーションやミドルウェア
がUTF-8で動作するのかの検証は必要ないですよね?
もし認識が違っておりましたら、教えて下さい。
サーブレットとか画面周りの知識が無いので、質問の仕方がおかしいところが
ありましたら、申し訳ありません。
No.2ベストアンサー
- 回答日時:
Bruce Eckel, "Thinking in Java (4th Edition)" (Prentice Hall, 2006)
によると、p.922~p.923に、次のようにあります。
Java 1.1 made some significant modifications to the fundamental I/O stream library.
When you see the Reader and Writer classes, your first thought (like mine) might be that these were meant to replace the InputStream and OutputStream classes.
But that’s not the case.
Although some aspects of the original streams library are deprecated (if you use them you will receive a warning from the compiler), the InputStream and OutputStream classes still provide valuable functionality in the form of byte-oriented I/O, whereas the Reader and Writer classes provide Unicode-compliant, character-based I/O. In addition:
1. Java 1.1 added new classes into the InputStream and OutputStream hierarchy, so it’s obvious those hierarchies weren’t being replaced.
2. There are times when you must use classes from the “byte” hierarchy in combination with classes in the “character” hierarchy. To accomplish this, there are “adapter” classes:
InputStreamReader converts an InputStream to a Reader and OutputStreamWriter converts an OutputStream to a Writer.
The most important reason for the Reader and Writer hierachies is for internationalization.
The old I/O stream hierarchy supports only 8-bit byte streams and doesn't handle the 16-bit Unicode characters well.
Since Unicode is used for internationalization (and Java's native char is 16-bit Unicode), the Reader and Writer hierarchies were added to support Unicode in all I/O operations.
In addition, the new libraries are designed for faster operations than the old.
>Linuxマシンの時は、入力テキストファイルは普通、EUC-JPと思います。
私の環境ではUTF-8です。
>関連する他のアプリケーションやミドルウェア
>がUTF-8で動作するのかの検証は必要ないですよね?
あります。(レガシーなものを使う場合等)
もっとも、こういう文字コードの問題を解決するためにUnicodeが多くの方々の多大の努力によって開発されたにも関わらず、未だにUnicodeを使わずに、単にWindowsマシンだというだけで、ShiftJISを使う人が未だにあとをたたないのは、全くはた迷惑な話で、改善していって欲しいもんです。
お礼が遅くなって、大変申し訳ありませんでした。ご回答、どうもありがとうございました。
Linuxマシンは最近はUTF-8になっているのですね。自分が使っていたものが古かったです。
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
関連するカテゴリからQ&Aを探す
おすすめ情報
- ・漫画をレンタルでお得に読める!
- ・人生のプチ美学を教えてください!!
- ・10秒目をつむったら…
- ・あなたの習慣について教えてください!!
- ・牛、豚、鶏、どれか一つ食べられなくなるとしたら?
- ・【大喜利】【投稿~9/18】 おとぎ話『桃太郎』の知られざるエピソード
- ・街中で見かけて「グッときた人」の思い出
- ・「一気に最後まで読んだ」本、教えて下さい!
- ・幼稚園時代「何組」でしたか?
- ・激凹みから立ち直る方法
- ・1つだけ過去を変えられるとしたら?
- ・【あるあるbot連動企画】あるあるbotに投稿したけど採用されなかったあるある募集
- ・【あるあるbot連動企画】フォロワー20万人のアカウントであなたのあるあるを披露してみませんか?
- ・映画のエンドロール観る派?観ない派?
- ・海外旅行から帰ってきたら、まず何を食べる?
- ・誕生日にもらった意外なもの
- ・天使と悪魔選手権
- ・ちょっと先の未来クイズ第2問
- ・【大喜利】【投稿~9/7】 ロボットの住む世界で流行ってる罰ゲームとは?
- ・推しミネラルウォーターはありますか?
- ・都道府県穴埋めゲーム
- ・この人頭いいなと思ったエピソード
- ・準・究極の選択
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
vba クリップボードクリアにつ...
-
IISワーカープロセスが原因でCP...
-
unzip32.dllの利用について(64b...
-
JAVAアプレットとか。
-
VB.net2003のプロジェクト
-
windows liveメールダウンロー...
-
使用しているJUnitのバージョン...
-
VBAの「for i=1 to cells(…」...
-
JSPファイルで生じるエラーをど...
-
javacのコンパイルでファイルが...
-
CrystalReportsのバージョン確...
-
URLDownloadToFileのコピペで64...
-
.NETでEXCHANGE SERVERのメー...
-
EclipseでJavaコンパイラのバー...
-
javaでの#if 0 #endif文
-
MSCOMCTL.OCXのアップデートの方法
-
Javaでのエラーについて
-
【javaコンパイル時のエラーに...
-
バージョン番号とリリース番号...
-
visual stadio 参照問題
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
vba クリップボードクリアにつ...
-
IISワーカープロセスが原因でCP...
-
unzip32.dllの利用について(64b...
-
プラグインとパッチの違いは?
-
C++からC#へ
-
32ビットのアプリで、64ビットO...
-
C#のメモリマップドファイルに...
-
AccessとVBの違いについて
-
appleスクリプトでアプリケーシ...
-
ログオフ中でもアプリケーショ...
-
意味が分からないエラー
-
java起動時の日本語引数文字化...
-
Java でネイティブアプリケーシ...
-
帳票出力について
-
JavaアプレットはWebブラウザ上...
-
C#のWindowsフォームアプリケー...
-
こんな事は可能でしょうか?
-
[VB.2005]クライアントからWEB...
-
VBScript/Com+のメリット/デメ...
-
ASP(VB).NETでの背景色変更
おすすめ情報