Jump to content

How To Use UTF Characters in a batch file


Recommended Posts

Learned something today. I had an error with some software that relies on a command being called through a batch file. My code that has worked for years was all of a sudden failing. After a bit of digging I noticed my user has some French characters in their surname, so the path to the temporary files I was generating had these non-ASCII characters in it!

If I ran my batch file from CMD.exe Windows was replacing the French character with multiple ASCII characters which is obviously not going to work.

The simple solution is to change the active code page to 65001 which is UTF-8. (See: https://stackoverflow.com/questions/11962172/echo-utf-8-characters-in-windows-batch), so all I did was add the

chcp 65001

command to the beginning of the batch file et voilà!

 

  • Thanks 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.