gpt4 book ai didi

powershell - 将Unicode文字分配给PowerShell哈希表

转载 作者:行者123 更新时间:2023-12-03 01:16:19 25 4
gpt4 key购买 nike

已经很晚了,我今晚完蛋了-有人可以帮忙吗?我是否需要做一些额外的工作才能将这些Unicode字符串分配为文字?

首次尝试创建包含双重编码和所需键值对的哈希表:

[string] $double_encoded_values = @{
"€" = "€";
"‚" = "‚";
"Æ’" = "ƒ";
"„" = "„";
"…" = "…";
"â€" = "†";
"‡" = "‡";
"ˆ" = "ˆ";
"‰" = "‰";
"Å" = "Š";
"‹" = "‹";
"Å’" = "Œ";
"Ž" = "Ž";
"‘" = "‘";
"’" = "’";
"“" = "“";
"â€" = "”";
"•" = "•";
"–" = "–";
"—" = "—";
"Ëœ" = "˜" ;
"â„¢" = "™";
"Å¡" = "š";
"›" = "›";
"Å“" = "œ";
"ž" = "ž";
"Ÿ" = "Ÿ";
"¡" = "¡";
"¢" = "¢";
"£" = "£";
"¤" = "¤";
"Â¥" = "¥";
"¦" = "¦";
"§" = "§";
"¨" = "¨";
"©" = "©";
"ª" = "ª";
"«" = "«";
"¬" = "¬";
"®" = "®";
"¯" = "¯";
"°" = "°";
"±" = "±";
"²" = "²";
"³" = "³";
"´" = "´";
"µ" = "µ";
"¶" = "¶";
"·" = "·";
"¸" = "¸";
"¹" = "¹";
"º" = "º";
"»" = "»";
"¼" = "¼";
"½" = "½";
"¾" = "¾";
} # $double_encoded_values

我的版本:
PS C:\Windows\system32> $PSVersionTable.PSVersion

Major Minor Build Revision
----- ----- ----- --------
4 0 -1 -1

收到错误:
At line:20 char:12
+ "–" = "–";
+ ~
Missing '=' operator after key in hash literal.
At line:20 char:12
+ "–" = "–";
+ ~
The hash literal was incomplete.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEqualsInHashLiteral

引用: http://www.i18nqa.com/debug/utf8-debug.html

最佳答案

PowerShell将中的–视为双引号,有效地转义了"中的结尾"–"
使用单引号可以避免PowerShell尝试解析键名和值:

@{
'–' = '-'
}

关于powershell - 将Unicode文字分配给PowerShell哈希表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28979543/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com