# Watched words upload should support UTF8

**URL:** https://meta.discourse.org/t/watched-words-upload-should-support-utf8/112260
**Category:** Bug
**Created:** [08.Март.2019 05:26:20 UTC](https://meta.discourse.org/t/watched-words-upload-should-support-utf8/112260 "2019-03-08T05:26:20Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Kevin\_Sun](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kevin_sun/32/133391_2.png) [@Kevin\_Sun](https://meta.discourse.org/u/Kevin_Sun)
#### Post date: [08.Март.2019 05:26:20 UTC](https://meta.discourse.org/t/watched-words-upload-should-support-utf8/112260/1 "2019-03-08T05:26:20Z")

</div>

when I upload a file(UTF8) with Chinese character, it were garbled . is this a Bug?  
My Discourse version is : 2.3.0.beta3

![07%20AM](https://global.discourse-cdn.com/meta/original/3X/6/f/6f11543bad251a4de70fe16316a6b3b7d76d1ba8.png)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [12.Март.2019 00:51:21 UTC](https://meta.discourse.org/t/watched-words-upload-should-support-utf8/112260/2 "2019-03-12T00:51:21Z")

</div>

Just confirming this is working fine if you use the UX, but has trouble when you upload a file?

---

<div class="post-metadata">

### Author: ![Tiger\_Young](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tiger_young/32/134579_2.png) [@Tiger\_Young](https://meta.discourse.org/u/Tiger_Young)
#### Post date: [20.Март.2019 09:00:25 UTC](https://meta.discourse.org/t/watched-words-upload-should-support-utf8/112260/3 "2019-03-20T09:00:25Z")

</div>

from the following code, it seems only file encoded with ISO-8859-1 is supported to be uploaded.

```
 Scheduler::Defer.later("Upload watched words") do
      begin
        File.open(file.tempfile, encoding: "ISO-8859-1").each_line do |line|
          WatchedWord.create_or_update_word(word: line, action_key: action_key) unless line.empty?
        end
        data = { url: '/ok' }
      rescue => e
        data = failed_json.merge(errors: [e.message])
      end
      MessageBus.publish("/uploads/csv", data.as_json, client_ids: [params[:client_id]])
    end

    render json: success_json

```

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [20.Март.2019 11:05:52 UTC](https://meta.discourse.org/t/watched-words-upload-should-support-utf8/112260/4 "2019-03-20T11:05:52Z")

</div>

@neil, do you remember why you enforced that encoding?

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [20.Март.2019 14:09:26 UTC](https://meta.discourse.org/t/watched-words-upload-should-support-utf8/112260/5 "2019-03-20T14:09:26Z")

</div>

Hmm no I don’t. Probably copy-pasted from somewhere else.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [21.Март.2019 00:19:16 UTC](https://meta.discourse.org/t/watched-words-upload-should-support-utf8/112260/6 "2019-03-21T00:19:16Z")

</div>

UTF-8 would be a more common encoding.

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [21.Март.2019 21:05:10 UTC](https://meta.discourse.org/t/watched-words-upload-should-support-utf8/112260/10 "2019-03-21T21:05:10Z")

</div>

Fixed:

[https://github.com/discourse/discourse/commit/1812a38f0a4194eba799ca56b492986db0088498](https://github.com/discourse/discourse/commit/1812a38f0a4194eba799ca56b492986db0088498)

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [21.Март.2019 21:18:01 UTC](https://meta.discourse.org/t/watched-words-upload-should-support-utf8/112260/11 "2019-03-21T21:18:01Z")

</div>

@Kevin_Sun Can you update to the latest version and try again? You should now be able to import watched words with Chinese characters.

---

<div class="post-metadata">

### Author: ![Kevin\_Sun](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kevin_sun/32/133391_2.png) [@Kevin\_Sun](https://meta.discourse.org/u/Kevin_Sun)
#### Post date: [22.Март.2019 23:00:11 UTC](https://meta.discourse.org/t/watched-words-upload-should-support-utf8/112260/12 "2019-03-22T23:00:11Z")

</div>

@zogstrip yes, after upgrade to latest, it works, thank you so much

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [23.Март.2019 07:00:06 UTC](https://meta.discourse.org/t/watched-words-upload-should-support-utf8/112260/13 "2019-03-23T07:00:06Z")

</div>

This topic was automatically closed after 33 hours. New replies are no longer allowed.
