Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
More non english characters
#4
(Apr-17-2021, 03:13 PM)johnboy1974 Wrote:
(Apr-17-2021, 11:48 AM)snippsat Wrote: Your previous Thread
There talk about using json and not text when get data from API.
So if want to write as text file or something else use always utf-8 encoding when read and write.
with open('out.txt', 'w', encoding='utf-8') as f_out:
    s = 'Diósgyőr'
    f_out.write(s)

with open('out.txt', 'r', encoding='utf-8') as f:
    print(f.read())
Output:
Diósgyőr

HI mate,

Nice one and indeed about that earlier post. I remember the json converting it magically and thought maybe I had to convert it back.

Many thanks for that!

Cheers,
J


Hi,

Interestingly, I'm getting a different error.

JSON returns '1a Divisió'
File is writing: 1a Divisió

I've tried using utf-16 for no reason but it complained about a BOM.

response = requests.request("GET", url, headers=headers)
json_data = response.json()
myData = json_data['response']
.
.
.
f = open(strLeaguesFile, 'a', encoding='utf-8')
f.write(strLeagueName)
CHeers,
J
Reply


Messages In This Thread
More non english characters - by johnboy1974 - Apr-17-2021, 11:32 AM
RE: More non english characters - by snippsat - Apr-17-2021, 11:48 AM
RE: More non english characters - by johnboy1974 - Apr-17-2021, 03:13 PM
RE: More non english characters - by johnboy1974 - Apr-17-2021, 04:06 PM
RE: More non english characters - by snippsat - Apr-17-2021, 05:33 PM
RE: More non english characters - by johnboy1974 - Apr-17-2021, 05:52 PM
RE: More non english characters - by snippsat - Apr-17-2021, 07:24 PM
RE: More non english characters - by johnboy1974 - Apr-23-2021, 01:44 PM
RE: More non english characters - by snippsat - Apr-23-2021, 02:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  (python) Can i get some help fixing a English to Morse translator? Pls AlexPython 7 1,719 Sep-12-2022, 02:55 AM
Last Post: AlexPython
  write a program which prints the day in english ben1122 10 4,219 Jul-25-2021, 05:55 PM
Last Post: ben1122
  Remove escape characters / Unicode characters from string DreamingInsanity 5 14,226 May-15-2020, 01:37 PM
Last Post: snippsat
  English interpretation of the following file handing snippet mortch 5 3,309 May-30-2019, 08:10 AM
Last Post: mortch
  TreeTagger : parameter file invalid : english.par Raph0909 0 2,855 Apr-12-2019, 12:12 PM
Last Post: Raph0909
  Cobol code to English like language/Identify ENDIF for correspoding IF in a string Venkat 6 4,366 Apr-12-2018, 01:05 PM
Last Post: buran
  how coding microphone receive non-English? TedHanaka 1 2,438 Feb-12-2018, 02:13 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020