4

スウェーデンの会社向けにGoogleマップの実装を構築しているため、言語にはä、å、öの多くの用途があります。私は、各マップマーカーの "title"属性を除き、特殊文字を正しく表示するのに問題はありません(サイトの文字セットはUTF-8です)。マーカーのための私のコードは、(あなたが角括弧内のすべてを無視することができます)です。Googleマップv3 - マーカータイトルにアクセント付き文字を使用する

var marker = new google.maps.Marker({ 
    position: [coordinates], 
    map: [map container div], 
    icon: [icon image], 
    title: "Läs mer om "+[text from JSON] //THIS IS WHERE THE PROBLEM IS 
}); 

私は、地図上のマーカーの上に置くと、ツールチップは、「LSマーオム...」として起動します。 Javascriptで "ä"をäに変更すると、ツールチップに "Läs mer om..."と表示されます。

キッカーは、サイトのどこにいても、生のHTMLやCMSによって配置された生成テキストに直接特殊文字を使用するものです。 Googleマップの実装ではしかクラッキングしていません。

また、サイトが完全にスウェーデン語であることを考えると、これはかなり重大な問題です。居住の天才からの明るいアイデア?

+1

私はアラビア語でGoogleマップアプリを構築しましたが、100%アラビア語ですごくいいですが、ファイルエンコードをUTF-8に変換することをお勧めします。http://manual.macromates.com/en /saving_files.html – tawfekov

+0

ファイルのエンコーディングはすべて、ページの文字セットと同じように、すでにUTF-8に設定されています。私が言ったように、すべてのアクセント付き文字は、Googleマップの実装を除いてどこでもうまく機能しています。 – Scottie

+1

私はそれをもっと詳しく説明します。 – tawfekov

答えて

3

あなたはそれをテストする必要がある場合ので、高速 console.log("L\u00e4s mer om")またはalert("L\u00e4s mer om")それだろう出力 「LASのマーOM」

ソースしてみてください、私はそれを試してみる持っていたし、それがここで働いていた、

http://www.ietf.org/rfc/rfc4627.txt

2.5. Strings 
    The representation of strings is similar to conventions used in the C 
    family of programming languages. A string begins and ends with 
    quotation marks. All Unicode characters may be placed within the 
    quotation marks except for the characters that must be escaped: 
    quotation mark, reverse solidus, and the control characters (U+0000 
    through U+001F). 

    Any character may be escaped. If the character is in the Basic 
    Multilingual Plane (U+0000 through U+FFFF), then it may be 
    represented as a six-character sequence: a reverse solidus, followed 
    by the lowercase letter u, followed by four hexadecimal digits that 
    encode the character's code point. The hexadecimal letters A though 
    F can be upper or lowercase. So, for example, a string containing 
    only a single reverse solidus character may be represented as 
    "\u005C". 

    Alternatively, there are two-character sequence escape 
    representations of some popular characters. So, for example, a 
    string containing only a single reverse solidus character may be 
    represented more compactly as "\\". 

    To escape an extended character that is not in the Basic Multilingual 
    Plane, the character is represented as a twelve-character sequence, 
    encoding the UTF-16 surrogate pair. So, for example, a string 
    containing only the G clef character (U+1D11E) may be represented as 
    "\uD834\uDD1E". 

説明:

0123何をすべきか、その後

{ 
    position: [coordinates], 
    map: [map container div], 
    icon: [icon image], 
    title: "Läs mer om "+[text from JSON] //THIS IS WHERE THE PROBLEM IS 
} 

大丈夫上部の上場規則に従わなければならないので、マーカー以来

は、JSオブジェクトである??? <?php echo json_encode("Läs mer om "); ?>を使用するか、サーバー側の言語は

です。値をJSONオブジェクトに追加するか、手動で書き込んでください。

+0

Brilliant!これは、このタイトルと置き換えようとしています。それは完全にそれを分類した。ありがとうございました! – Scottie

+0

あなたはScottieを歓迎します! :) – tawfekov

+0

申し訳ありませんが、私はまだそれを取得しません。私はASP.NET MVC 4を使用しています、サーバー側の言語はC#です、どうすればいいですか? – AnhTriet

関連する問題