UTF-8 Error Occurs When Writing Japanese in Flask-Bootstrap

Asked 2 years ago, Updated 2 years ago, 118 views

I am doing web development with Flask and Bootstrap, but when I write Japanese in Bootstrap code, I get an error like UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 1303: invalid start byte.

How can I prevent errors even if I write in Japanese?

Please give me an answer.

Here's the code.

{%extends"index.html"%}

<head>
<metacharset="utf-8">
</head>
{% US>block content%}
<div class="container">
<div class="card card-container w-75mx-auto">
 <form method="POST" action="">
 {{ form.hidden_tag()}}
 <fieldset class="form-group">
 <center>
 <img id="profile-img" class="profile-img-card img-responsive" src="//ssl.gstatic.com/accounts/ui/avatar_2x.png" style="border-radius: 100%"/>
 </center>
   <legend class="border-bottom mb-4">Join Today</legend>
   <div class="form-group">
   {{form.username.label(class="form-control-label")}}
   {{ form.username(class="form-control w-75mx-auto")}}
   </div>
   <div class="form-group">
     {{ form.email.label(class="form-control-label")}}
     {{ form.email(class="form-control w-75mx-auto")}}
   </div>

<div class="form-group">
     {{ form.password.label(class="form-control-label")}}
     {{ form.password(class="form-control w-75mx-auto")}}
   </div>

<div class="form-group">
{{ form.confirm_password.label(class="form-control-label")}}
{{ form.confirm_password(class="form-control w-75mx-auto")}}
   </fieldset>
   <div class="form-group">
   {{ form.submit(class="btn btn-block btn-primary w-75mx-auto")}}
   </div>
 </form>
 </div>

 <div class="border-top pt-3">
 <small class="text-muted">
 Do you already have an account?<a class="ml-2" href="{url_for('login')}}">Login</a>
 </small>
 </div>

 {% endblock content%}

flask

2022-09-30 18:59

1 Answers

0x82 is already the first byte of the SJIS expression, such as s, so the saved file does not appear to be UTF-8.
Review your editor settings and save specifications to ensure you save it as UTF-8 and try again.

This post was edited based on @Ooper's Comment and posted as Community Wiki.This post was edited based on @Ooper's Comment and posted as Community Wiki.


2022-09-30 18:59

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.