奇怪的学校作业,关于在 powershell 中显示表情符号

Odd school assignment, about displaying emojis in powershell

很高兴接到了在Powershell中发表情包的任务,唯一的问题是必须在同一行,而且是三个。这是我的第一份作业,我们之前没有这方面的教学,所以在谷歌搜索和搜索 YouTube 之后,我最好的照片是下面这个,但是,它出现了一些错误,说明价值太高或太低。

完整错误文本:使用“2”参数调用“ToInt32”时出现异常:“该值对于 UInt32 来说太大或太小。” 在 C:\Users\EG\Downloads\Herningsholm\Powershell H1\Hardware Information.ps1: 3 char: 5 $ UnicodeInt = [System.Convert] :: toInt32 ($ StrippedUnicode, 16) CategoryInfo: NotSpecified: (:) [], MethodInvocationException FullyQualifiedErrorId: OverflowException

$FullUnicode = ('U+1F60E') + ('U+1F436') + ('U+1F642')
$StrippedUnicode = $FullUnicode -replace 'U\+',''
$UnicodeInt = [System.Convert]::toInt32($StrippedUnicode,16)
[System.Char]::ConvertFromUtf32($UnicodeInt)

试试这个: 完整的表情符号列表 > here

# saves unicode for each emoji https://unicode.org/emoji/charts/full-emoji-list.html
$FullUnicode0 = 'U+1F606'
$FullUnicode1 = 'U+1F605'
$FullUnicode2 = 'U+1F605'

# removes the U+ bit
$StrippedUnicode0 = $FullUnicode0 -replace 'U\+',''
$StrippedUnicode1 = $FullUnicode1 -replace 'U\+',''
$StrippedUnicode2 = $FullUnicode2 -replace 'U\+',''

# Converts the value of the specified object to a 32-bit signed integer
$UnicodeInt0 = [System.Convert]::toInt32($StrippedUnicode0,16)
$UnicodeInt1 = [System.Convert]::toInt32($StrippedUnicode1,16)
$UnicodeInt2 = [System.Convert]::toInt32($StrippedUnicode2,16)

# Converts the specified Unicode code point into a UTF-16 encoded string so that you have an emoji
$Emoji0 = [System.Char]::ConvertFromUtf32($UnicodeInt0)
$Emoji1 = [System.Char]::ConvertFromUtf32($UnicodeInt1)
$Emoji2 = [System.Char]::ConvertFromUtf32($UnicodeInt2)

write-host "$($Emoji0), $($Emoji1), $($Emoji2)"