Python Forum
[SOLVED] Correct way to convert file from cp-1252 to utf-8?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Correct way to convert file from cp-1252 to utf-8?
#2
You could replace line 25 with
data = rawdata.decode(encoding=encoding)
Then at line 27, open the file in binary mode, without encoding because data is normally a byte string after the encode() of line 26.
« We can solve any problem by introducing an extra level of indirection »
Reply


Messages In This Thread
RE: Correct way to convert file from cp-1252 to utf-8? - by Gribouillis - Feb-26-2024, 03:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Convert File to Data URL michaelnicol 3 1,296 Jul-08-2023, 11:35 AM
Last Post: DeaD_EyE
  Python Script to convert Json to CSV file chvsnarayana 8 2,639 Apr-26-2023, 10:31 PM
Last Post: DeaD_EyE
  Loop through json file and reset values [SOLVED] AlphaInc 2 2,255 Apr-06-2023, 11:15 AM
Last Post: AlphaInc
Thumbs Up Convert an Interger into any base !? [Solved] SpongeB0B 8 1,534 Jan-16-2023, 10:24 AM
Last Post: SpongeB0B
  Convert Excel file into csv with Pipe symbol.. mg24 4 1,396 Oct-18-2022, 02:59 PM
Last Post: Larz60+
  Need Help: Convert .pcl file to .pdf file ManuRaval 6 2,639 Sep-13-2022, 01:31 PM
Last Post: ManuRaval
  [Solved by deanhystad] Create a zip file using zipfile library DZ_Galaxy 2 1,238 Aug-17-2022, 04:57 PM
Last Post: DZ_Galaxy
  Updating a config file [solved] ebolisa 8 2,693 Nov-04-2021, 10:20 AM
Last Post: Gribouillis
  |SOLVED] Glob JPGs, read EXIF, update file timestamp? Winfried 5 2,572 Oct-21-2021, 03:29 AM
Last Post: buran
  Convert legacy print file to XLSX file davidm 1 1,842 Oct-17-2021, 05:08 AM
Last Post: davidm

Forum Jump:

User Panel Messages

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