0

I'm trying something that has turned out truly annoying. I am a swede, and we have three characters that is somewhat unique (åäö ÅÄÖ). The script I am working on is network related so I need to replace these with a and o instead. That part is fairly straightforward

$A = $A.Replace('ä','a')

And so forth.

The problem turns out that if the 'script' is not saved in UTF-8 the characters can turn out in many different ways, for example:

å  = å
Ã¥ = å
㥠= å

And the latest problem turned out that it doesn't even recognise the character when it looks correct.

If the script must be saved as UTF-8 it's gonna be really hard to maintain. As, as soon as someone opens the script in an editor and that editor saves the script in a different encoding the script is broken.

So my question is. Is there any best praxis and/or way to define the script to use UTF-8 in the strings?

Thanks for any suggestions.

  • I think the dupe target I chose would be a better approach. I can remove if it you truly disagree but it answers the title better than your proposed approach. Look at the high rated answer and not the marked answer. – Matt Jun 15 '18 at 15:27
  • Thanks @Matt for that link, was looking for it for some time. The easiest way seems to be `'åäö ÅÄÖ'.Normalize("FormD") -replace '\p{M}'` returning `aao AAO` –  Jun 15 '18 at 15:46
  • Sorry for the double post. Been searching like crazy for a solution, but just couldn't find anything about this. Awesome magic there LotPings. It works great, just not sure HOW or WHY it works. If possible, please explain. I'm here to learn. – Patrik Westlin Jun 15 '18 at 16:53

0 Answers0