# 다른 웹사이트에 Discourse를 임베드할 때 umlaut 관련 문제

**URL:** https://meta.discourse.org/t/problem-with-umlauts-when-embedding-discourse-on-another-website/288171
**Category:** Support
**Tags:** embedding
**Created:** [12월 10, 2023, 9:41오후 UTC](https://meta.discourse.org/t/problem-with-umlauts-when-embedding-discourse-on-another-website/288171 "2023-12-10T21:41:29Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![limetti](https://avatars.discourse-cdn.com/v4/letter/l/e5b9ba/32.png) [@limetti](https://meta.discourse.org/u/limetti)
#### Post date: [12월 10, 2023, 9:41오후 UTC](https://meta.discourse.org/t/problem-with-umlauts-when-embedding-discourse-on-another-website/288171/1 "2023-12-10T21:41:29Z")

</div>

여기([Embed Discourse comments on another website via Javascript - #453 by limetti](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/453))에서 설명한 대로, 내 웹사이트에 Discourse를 임베드하면 제목이 올바르게 파싱됩니다. 하지만 제목에 우물라움(umlaut)이 포함되어 있으면 “Ich würde” 같은 제목이 “Ich wÃ¼rde”로 표시됩니다.

이것은 일반적인 문제인지, 아니면 제 페이지의 문제인지, 혹은 이 문제를 우회할 수 있는 방법이 있는지요? 감사합니다!

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [12월 11, 2023, 5:08오전 UTC](https://meta.discourse.org/t/problem-with-umlauts-when-embedding-discourse-on-another-website/288171/2 "2023-12-11T05:08:05Z")

</div>

> [@limetti](#):
>
> “Ich würde”와 같은 제목이 “Ich wÃ¼rd”로 변환됩니다

이것은 전형적인 “잘못된 코덱” 문제입니다.

테스트 케이스로, (이 예시에서는 python을 사용하여) 게시물의 원시 데이터를 읽으면:

```plaintext
In [1]: import urllib

In [2]: u = urllib.request.urlopen('https://meta.discourse.org/posts/1418409/raw')

In [3]: r = u.read(); r
Out[3]: b'As described here (https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/453), when embedding Discourse into my website, the title is correctly parsed. But as it contains umlauts, titles like \xe2\x80\x9cIch w\xc3\xbcrde\xe2\x80\x9d end up in \xe2\x80\x9cIch w\xc3\x83\xc2\xbcrde\xe2\x80\x9d.\n\nIs this a general problem, a problem with my page or any workaround for that? Thanks!'

```

우리는 _바이트_를 얻지만, 이를 어떻게 디코딩해야 하는지 알지 못합니다. 그러나 응답 헤더 중 하나가 UTF-8을 사용해야 한다고 알려줍니다:

```plaintext
In [4]: u.headers['content-type']
Out[4]: 'text/plain; charset=utf-8'

In [5]: r.decode('utf-8')
Out[5]: 'As described here (https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/453), when embedding Discourse into my website, the title is correctly parsed. But as it contains umlauts, titles like “Ich würde” end up in “Ich wÃ¼rde”.\n\nIs this a general problem, a problem with my page or any workaround for that? Thanks!'

In [6]: print(r.decode('utf-8'))
As described here (https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/453), when embedding Discourse into my website, the title is correctly parsed. But as it contains umlauts, titles like “Ich würde” end up in “Ich wÃ¼rde”.

Is this a general problem, a problem with my page or any workaround for that? Thanks!

```

문자가 게시한 그대로임을 알 수 있습니다. 그러나 해당 바이트에 대한 잘못된 해석이 이루어지면 — 특히 [UTF-8](https://en.wikipedia.org/wiki/UTF-8) 대신 [ISO-8859-1](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)로 해석하는 일반적인 실수가 발생하는 경우(아래에서 명확성을 위해 문자열을 줄임) — 다음과 같은 결과가 나옵니다:

```plaintext
In [7]: snippet = r[220:255]; snippet
Out[7]: b'titles like \xe2\x80\x9cIch w\xc3\xbcrde\xe2\x80\x9d end up'

In [8]: snippet.decode('utf-8')
Out[8]: 'titles like “Ich würde” end up'

In [9]: snippet.decode('iso-8859-1')
Out[9]: 'titles like â\x80\x9cIch wÃ¼rdeâ\x80\x9d end up'

```

이것을 `print`하면 터미널이 멈춥니다. 놀랍군요. 😃

요약하자면: Discourse에서 게시물 데이터를 가져오는 데 사용하는 도구가 utf-8 대신 iso-8859-1로 처리하고 있습니다.

(추측) 아마도 Discourse 사이트에서 가져온 원시 바이트를 iso-8859-1 코드페이지로 서빙되는 페이지에 임베드하고 있는 것 같습니다.

---

<div class="post-metadata">

### Author: ![limetti](https://avatars.discourse-cdn.com/v4/letter/l/e5b9ba/32.png) [@limetti](https://meta.discourse.org/u/limetti)
#### Post date: [12월 13, 2023, 7:53오전 UTC](https://meta.discourse.org/t/problem-with-umlauts-when-embedding-discourse-on-another-website/288171/3 "2023-12-13T07:53:25Z")

</div>

힌트 주셔서 정말 감사합니다. 정말로 meta 태그의 UTF-8이 title 태그 뒤에 있었네요 😉

이제 잘 작동합니다!

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [1월 12, 2024, 7:53오전 UTC](https://meta.discourse.org/t/problem-with-umlauts-when-embedding-discourse-on-another-website/288171/4 "2024-01-12T07:53:35Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
