File Load Some bytes have been replaced with the Unicode substitution character while loading file

21,969

Solution 1

I started to get this error after switching on (for test purposes) the new setting "Beta: Use Unicode UTF-8 for worldwide language support" in the recent Windows 10 Spring 2018 update.

The message would then appear for every file that has non-ascii characters (German Umlauts mostly in my case) and had not been stored as UTF8 before.

Short-time fix: Revert the setting to not use UTF-8 as the "Current language for non-unicode programs", but use a language with the special characters that are used in the source files.

Long-time fix: Convert all your soure files to UTF-8.

Solution 2

I fixed this issue by changing my "Language for non-Unicode programs" setting to "English (United States)". If you are using Windows 10, you can find it in "Control Panel -> Clock, Language, and Region -> Region -> Administrative".

Screenshot of the Region Settings dialog in Windows

Solution 3

I've just faced the same problem. It needs to open a file a save it back again. I guess some kinda tool that could do that in a batch will do the trick.

upd: Actually seems that's not helping... Looking for another solution

upd2: Resaving a file actually helps, but you have to disable this option:

Debugging\General\Require source files to exactly match the original version

Solution 4

I met the same problem. it seems vs2010 is trying to read the source file using wrong encoding. I open the file with editpad and convert it to utf-8, and it becomes ok.

Solution 5

If you are using Windows 10, you can find it in Control Panel -> Clock, Language, and Region -> Region -> Administrative. From Language for non-Unicode programs, select "Select system locale".

Uncheck box "Beta: Use Unicode UTF-8 for worldwide language support". Press ok. You will be prompted to restart windows - do it.

After that if you're developer - you might encounter compile errors in Visual studio like this:

error C2855: command-line option "source-charset" inconsistent with precompiled header

Just rebuild whole project and problem will disappear.

Share:
21,969
Nour
Author by

Nour

bachelor degree in Economics, I have 4 years experience in Software Development : C# ,Asp.Net , MVC , WCF, Design Patterns, Nhibernate CAB ( Composite UI Application Block) Web Client Software Factory. Team Foundation Server Administration. Sql Server 2005 Administration.

Updated on July 05, 2022

Comments

  • Nour
    Nour almost 2 years

    I was debugging in the .Net framework source code suddenly when I stepped into a file of theirs, visual studio 2010 raised this error:

    File Load:
    Some bytes have been replaced with the Unicode substitution character while loading file XXX, Saving the file will not preserve the original file contents.

    when I click OK, the file is marked as unsaved, and when you try to save it, it says that the file is locked, but I can overwrite the file. I don't know what does this message means.

    And why now, not the first time when visual studio downloaded the file from Symbol server?