MSBuild, XAML & international characters

More a note to myself, because I’m sure, will bump again in this issue later.

I’ve edited some strings in our XAML files to correct some french words. Someone pointed that I’m not playing well with french-specific characters (you now, the é, è, à, …). After committing my changes our build server went down with a strange error:

error MC3000: ‘Invalid character in the given encoding. Line 58, position 47.’ XML is not valid.

Hmm. On my machine VS has built and run it without any problems. Compiling from command line – same error.

Problem: Compiler launched from command line cannot process the source file because of international characters that I’ve just added.

Solution: Save source file explicitly in UTF-8 encoding to preserve international characters.

How To:

  • open the problematic file in Visual Studio.
  • on the File menu click “Advanced Save Options
  • from “Encoding” combo select “Unicode (UTF-8 …
  • click OK.

You’re set. Commit to please the build server and rest of the team waiting for green.

Advertisement
  1. #1 by Guido on January 21, 2010 - 09:01

    Hi Valeriu,
    thanks for this piece of information.
    In my personal experience there is one caveat with this approach:
    Changing the character encoding of files under source control in an TFS / VS 2008 environment can lead to problems in comparing and merging the file if this file was checked out by others during the encoding change.
    If only a few characters need to be taken from unicode, you could also reference them by their unicode entity name (e.g. “●” for the Password Character in Password box styles).
    Regards,
    Guido

    • #2 by Valeriu Caraulean on January 21, 2010 - 09:25

      Thank you Guido, haven’t knew that there can be issues with TFS.

      As for replacing only individual characters with unicode representations – that’s a nice trick. But it’s a “no way” if you have to internationalize your application.

  2. #3 by Guido on January 21, 2010 - 09:03

    the entitiy name above should read: “[ampersand]#x25CF;” .
    Grmpfl :o /

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.