掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
ウェブページのソース表示で文字化けを避けるには? (ID:40169)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
質問のサイトのCharSetはUTF8だから、以下のUtf8ToSjis関数でShiftJISへの変換は出来る。 //「BOMなし」の場合 function Utf8NToSjis(const s: string): string; var Len: integer; OutPwc: PWideChar; SIn: string; begin Result := ''; SIn := S + #0#0; Len := MultiByteToWideChar(CP_UTF8, 0, PChar(SIn), Length(SIn), nil, 0); if Len = 0 then raise Exception.Create('指定のUTF8文字列の変換は出来ません.'); OutPwc := AllocMem(Len * 2); try MultiByteToWideChar(CP_UTF8, 0, PChar(SIn), Length(SIn), OutPwc, Len); WideCharToStrVar(OutPwc, Result); finally FreeMem(OutPwc); end; end; //「BOMあり」の場合 function Utf8ToSjis(const s: string): string; var ss: string; begin ss := s; Delete(ss, 1, 3); Result := Utf8NToSJis(ss); end; でもこの際、最新のIndy10に入れ替えた方がいいと思うけど。 http://ht-deko.minim.ne.jp/tech034.html(DEKOさんのページ) (ANSI 版 Delphi (5〜2007) に最新版の Indy10 をインストールする)
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.