I am trying to create a duplicate file finder for Windows. My program works well in Linux. But it writes NUL characters to the log file in Windows. This is due to the MBCS default file system encoding of Windows, while the file system encoding in Linux is UTF-8. How can I convert MBCS to UTF-8 to avoid this error?
MBCS to UTF-8: How to encode in Python
7.8k views Asked by achint chaudhary At
2
There are 2 answers
Related Questions in WINDOWS
- how to play a sounds in c# forms?
- Echo behaviour of Microsoft Windows Telnet Client
- Getting error while running spark-shell on my system; pyspark is running fine
- DirectX 9 With No SDK Installed - How To Translate a D3DMATRIX?
- Gradle 8.7 cannot find installed JDK 22 in IntelliJ
- 'IOException: The cloud file provider is not running', when trying to delete 'cloud' folder
- Cannot load modules/mod_dav_svn.so into server
- Issue with launching application after updating ElectronJs to version 28.0.0 on Windows and Linux
- 32-bit applications do not display some files in Windows 10
- 'bun' is not recognized as an internal or external command
- mkssecreenshotmgr taking a screenshot
- Next js installation in windows 7 os
- Can't resize a partition using Mini Tool?
- Is there any way to set a printer as default according with Active Directory Policy Security Group and PC hostname?
- Electron Printing not working on Windows (Works on Mac)
Related Questions in PYTHON-3.X
- SQLAlchemy 2 Can't add additional column when specifying __table__
- Writes to child subprocess.Popen.stdin don't work from within process group?
- Platform Generation for a Sky Hop clone
- What's the best way to breakup a large test in pytest
- chess endgame engine in Python doesn't work perfectly
- Function to create matrix of zeros and ones, with a certain density of ones
- how to create a polars dataframe giving the colum-names from a list
- Django socketio process
- How to decode audio stream using tornado websocket?
- Getting website metadata (Excel VBA/Python)
- How to get text and other elements to display over the Video in Tkinter?
- Tkinter App - My Toplevel window is not appearing. App is stuck in mainloop
- Can I use local resources for mp4 playback?
- How to pass the value of a function of one class to a function of another with the @property decorator
- Python ModuleNotFoundError for command line tools built with setup.py
Related Questions in PYTHON-3.5
- Debugging with python3.5 in VSCode
- Is Debian 12 compatible with Python 3.5.4? (Segmentation fault error)
- WSL with VS Code and python 3.5
- folders not deeleted with errors [WinError 145] The directory is not empty
- having application run error with python3 and flask
- How to create a tweet using V2 API without Tweepy?
- How to install object-detection library without downgrading Python version?
- discord.py remove roles from Discord bot
- how to downgrade python3.8.10 to 3.5.6 on ubuntu via the terminal?
- Reading alb logs in python using boto3 and athena
- match 2 dictionary with python and check both key and value
- * operation in python for 2-d matrix initialization
- python program to print sum of consecutive numbers in a range
- I can't install or run beautifulsoup
- AttributeError: 'DataFrame' object has no attribute '_data' [Not a duplicate]
Related Questions in MBCS
- Why is 'UNICODE' being defined?
- How to MIGRATE ANSI/MBCS Resources for Visual Studio 2019 C++ MFC project
- How to work with substrings / delete character when content is mixed single and double byte?
- MFC dialogs caption fails with Unicode
- How to create filename with characters that are not part of UTF-8 on Windows?
- Read *.txt file with German text, show it in my GUI -- characters with umlauts not correct
- Cannot create user at runtime with Query with parameters
- Everytime I build a unreal engine project, vs keeps warning like this: unable to get MBCS string
- how to read csv files with mbcs codec in Python on Linux?
- Is it guaranteed that trailing bytes in mbcs encodings are in specific range?
- MFC CEdit converts non-ascii characters to ascii
- Visual C++ - UTF-8 - CA2W followed by CW2T with MBCS - Possibly a bad idea?
- MBCS encoding unknown
- VSO/VSTS and MBCS
- Converting from Windows MBCS to UTF-8
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Tell Python to use UTF-8 on the log file. In Python 3 you do this by:
If you want to convert an MBCS string to UTF-8 you can switch string encodings:
Use
filename.encode(sys.getdefaultencoding())...to make the code work on Linux, as well.