reflex icon indicating copy to clipboard operation
reflex copied to clipboard

Stream did not contain valid UTF-8

Open Iced0368 opened this issue 3 years ago β€’ 2 comments

Describe the bug When characters such as Chinese characters and Hangul are initially rendered, they are converted into invalid characters and entered in index.js. Therefore, a stream did not contain valid UTF-8 error occurs.

For example:

def index():
    return pc.container(
        pc.text("ν•œκΈ€")
    )

app = pc.App()
app.add_page(index)
app.compile()

this code makes an error

class State(pc.State):
    text = "ν•œκΈ€"

def index():
    return pc.container(
        pc.text(State.text)
    )

app = pc.App(state=State)
app.add_page(index)
app.compile()

but this works. This obviously looks like a bug.

Screenshots invalid

index.js when the first code was compiled

** Specifics (please complete the following information):**

  • Python Version: 3.10.xx
  • Pynecone Version: 0.1.12
  • OS: Windows

Iced0368 avatar Jan 18 '23 15:01 Iced0368

I think my problem is similar. I wrote Pynecone's "To-do List" demo in your gallery. The placeholder on Input component, almost hangul characters go like image

martiniifun avatar Jan 19 '23 17:01 martiniifun

same quetision.I use Chinese to display the text and I hope to be able to solve this problem as soon as possible. @Alek99

nice2cu1 avatar Jan 23 '23 09:01 nice2cu1

I have a similar problem.After hard coding Chinese in the .py, then the compiled Corresponding Chinese of .js is garbled.

LumiaGG avatar Jan 24 '23 03:01 LumiaGG

Fix will be push soon this is the pr https://github.com/pynecone-io/pynecone/pull/332

Alek99 avatar Jan 24 '23 23:01 Alek99

The bug is caused by pynecone.components.tags.tag ,when format the props, the json.dumps function use ascii encode as default. The solution is add 'ensure_ascii=False' in every case of json.dumps uses. For example, change the code return json.dumps(prop.full_name) to return json.dumps(prop.full_name, ensure_ascii=False)

DeathShort avatar Mar 03 '23 10:03 DeathShort