Unicode characters not retained in PowerShell Studio IDE

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
PsCustomObject
Posts: 137
Last visit: Thu Mar 28, 2024 3:34 am

Unicode characters not retained in PowerShell Studio IDE

Post by PsCustomObject »

Product, version and build:
Sapien PowerShell Studio 2017 5.4.140.0 64 Bit

Operating system:
Windows 10 Enterprise 64 bit OS

PowerShell Version: 5.1.15063.413

As per subject I'm facing an issue with "special characters" being replaced in IDE, I have couple of scripts using a function I'm written that is replacing unicode characters like the following
  1. # a
  2.         'æ' = 'a'
  3.         'à' = 'a'
  4.         'â' = 'a'
  5.         'ã' = 'a'
  6.         'å' = 'a'
  7.         'ā' = 'a'
  8.         'ă' = 'a'
  9.         'ą' = 'a'
  10.         'ä' = 'a'
All is good until I save the script and find the characters replaced like this:
  1. # a
  2.         'æ' = 'a'
  3.         'à' = 'a'
  4.         'â' = 'a'
  5.         'ã' = 'a'
  6.         'å' = 'a'
  7.         'a' = 'a'
  8.         'a' = 'a'
  9.         'a' = 'a'
  10.         'ä' = 'a'
Being an hashtable I get errors about duplicate keys, funny thing this is not happening for all characters but only some of them.

Let me know if I can send you over some logs or other files/details to help with the debug, so far best solution I've found is keeping a copy of the hashtable in a text file and replace in the script between edit iterations.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Unicode characters not retained in PowerShell Studio IDE

Post by davidc »

I just ran a quick test and the encoding for the characters was preserving using a UTF-8 encoded file. What encoding does PowerShell Studio show for your file? You can find it in the status bar:
Statusbar - File Encoding.png
Statusbar - File Encoding.png (4.88 KiB) Viewed 2155 times
David
SAPIEN Technologies, Inc.
User avatar
PsCustomObject
Posts: 137
Last visit: Thu Mar 28, 2024 3:34 am

Re: Unicode characters not retained in PowerShell Studio IDE

Post by PsCustomObject »

Thanks David,

I will admit I completely ignored the reported encoding in the status bar, silly me, it was set to Windows 1152 I've now set it to UTF-8 and characters seems to stick now...

I will keep an eye on this but would say it's solved now.

Thanks a lot for your help!
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Unicode characters not retained in PowerShell Studio IDE

Post by davidc »

No problem. Thank you for the update.
David
SAPIEN Technologies, Inc.
This topic is 6 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.