GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    zunda (zundan@mastodon.zunda.ninja)'s status on Sunday, 09-Feb-2025 10:36:49 JST zunda zunda
    • かき@GNUsocialJP

    レスポンスヘッダのContent-typeがtext/html; charset=ISO-8859-1でなにをどうがんばっても日本語を提供できない回

    In conversation about 4 months ago from mastodon.zunda.ninja permalink
    • Embed this notice
      tateisu​ :force:​:r_9a: (tateisu@mastodon.juggler.jp)'s status on Sunday, 09-Feb-2025 14:07:41 JST tateisu​ :force:​:r_9a: tateisu​ :force:​:r_9a:
      in reply to
      • かき@GNUsocialJP

      @zundan HTMLなら https://e-words.jp/w/%E6%96%87%E5%AD%97%E5%8F%82%E7%85%A7.html とかで書けるはず

      In conversation about 4 months ago permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: p.e-words.jp
        文字参照とは - IT用語辞典
        文字参照【HTMLエンティティ】とは、HTMLやXMLなどSGMLから派生したマークアップ言語で、文書中に(ある特定の)文字を直接記すことが難しい場合に、特定の英数字や記号の組み合わせを代わりとして用いることができる記法。表記したい文字を、Unicode/ISO 10646の文字番号(コードポイント)で表す方式をHTMLでは「数値文字参照」(numeric character reference)、XMLでは「文字参照」(character reference)という。
    • Embed this notice
      zunda (zundan@mastodon.zunda.ninja)'s status on Sunday, 09-Feb-2025 14:07:41 JST zunda zunda
      in reply to
      • tateisu​ :force:​:r_9a:
      • かき@GNUsocialJP

      @tateisu なるほど〜。下記のようなサーバで試してみたら、少なくともSafariとChromeではユニコードからの数値参照の場合にレスポンスヘッダのcharsetを無視する感じになりそうですね。

      require "sinatra"

      def entity_reference(str, encoding)
      str.encode(encoding).codepoints.map{|c| "&##{c};"}.join
      end

      get "/euc-jp" do
      headers "Content-Type" => "text/html; charset=ISO-8859-1"
      "<html><body><p>#{entity_reference("こんにちは", "EUC-JP")}</p></body></html>\n"
      end

      get "/utf-8" do
      headers "Content-Type" => "text/html; charset=ISO-8859-1"
      "<html><body><p>#{entity_reference("こんにちは", "UTF-8")}</p></body></html>\n"
      end

      In conversation about 4 months ago permalink
    • Embed this notice
      tateisu​ :force:​:r_9a: (tateisu@mastodon.juggler.jp)'s status on Sunday, 09-Feb-2025 14:35:21 JST tateisu​ :force:​:r_9a: tateisu​ :force:​:r_9a:
      in reply to
      • かき@GNUsocialJP

      @zundan その出力に含まれるのは7bit ASCIIのテキストなのでiso-8859-1でバイト列から文字列に変換できて、次のHTMLパースの段階で文字参照はUnicode文字になります。レスポンスヘッダの文字コード指定は前者の方でちゃんと適用されています。

      In conversation about 4 months ago permalink
    • Embed this notice
      zunda (zundan@mastodon.zunda.ninja)'s status on Sunday, 09-Feb-2025 14:35:21 JST zunda zunda
      in reply to
      • tateisu​ :force:​:r_9a:
      • かき@GNUsocialJP

      @tateisu なるほどそれじゃあmataタグでもう一度文字コードを…と思ったのですがユニコード以外は今は規格外なのかもですね

      require "sinatra"

      def entity_reference(str, encoding)
      str.encode(encoding).codepoints.map{|c| "&##{c};"}.join
      end

      get "/euc-jp-equiv" do
      headers "Content-Type" => "text/html; charset=ISO-8859-1"
      <<"_HTML"
      <html>
      <meta http-equiv="content-type" content="text/html; charset=EUC-JP">
      <body><p>#{entity_reference("こんにちは", "EUC-JP")}</p></body>
      </html>
      _HTML
      end

      In conversation about 4 months ago permalink

      Attachments


      1. https://s3.amazonaws.com/zundan-mastodon/media_attachments/files/113/972/299/777/536/428/original/5ba4377daf44688a.png

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.