Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream did not contain valid UTF-8 #282

Closed
Iced0368 opened this issue Jan 18, 2023 · 5 comments · Fixed by #332
Closed

Stream did not contain valid UTF-8 #282

Iced0368 opened this issue Jan 18, 2023 · 5 comments · Fixed by #332
Labels
enhancement Anything you want improved

Comments

@Iced0368
Copy link

Iced0368 commented Jan 18, 2023

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
@Alek99 Alek99 added the enhancement Anything you want improved label Jan 19, 2023
@martiniifun
Copy link

martiniifun commented Jan 19, 2023

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

@nice2cu1
Copy link

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

@LumiaGG
Copy link
Contributor

LumiaGG commented Jan 24, 2023

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

LumiaGG added a commit to LumiaGG/pynecone-fix-utf8-Coding-error that referenced this issue Jan 24, 2023
@Alek99
Copy link
Contributor

Alek99 commented Jan 24, 2023

Fix will be push soon this is the pr #332

@Alek99 Alek99 linked a pull request Jan 24, 2023 that will close this issue
Alek99 pushed a commit that referenced this issue Jan 25, 2023
This fix is for some characters that were wrongly formatted because of lacking UTF-8
ACucos1 pushed a commit to ACucos1/rd-pynecone that referenced this issue Feb 28, 2023
This fix is for some characters that were wrongly formatted because of lacking UTF-8
@DeathShort
Copy link
Contributor

DeathShort commented Mar 3, 2023

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 added a commit to DeathShort/pynecone that referenced this issue Mar 3, 2023
…,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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Anything you want improved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants