相关疑难解决方法(0)

是否有Windows命令shell将显示Unicode字符?

假设我安装了具有相应字形的字体,是否有一个用于Windows XP的命令shell将显示Unicode字符?至少应该正确显示Unicode的两件事:

  • 目录列表.我不关心我必须键入什么(dir,ls,get-childitem等),只要名称中带有Unicode字符的文件带有正确的字形,而不是不可打印的字符框.
  • 文本文件内容列表.同样,只要字符被打印,对我来说无关紧要的是"少","更多","猫","狗"等.我认识到由于文件的字符编码,这更复杂,所以如果我必须在命令行上指定那对我没问题.

这是我到目前为止所尝试的:

  • CMD.EXE
  • Windows PowerShell; 包括多语言版本.
  • Cygwin bash

没运气.我甚至尝试为cmd/PowerShell安装自定义字体.PowerShell和cmd.exe似乎是Unicode感知的,因为我可以将不可打印的框复制/粘贴到那里,它将粘贴到具有正确字符的其他应用程序中.Cygwin(?)似乎转换为?字符和复制/粘贴中的字符.

有任何想法吗?

unicode powershell

49
推荐指数
4
解决办法
5万
查看次数

如何使用PowerShell将UTF-8字符传递给clip.exe而不转换为另一个字符集?

我是Windows和Powershell noobie.我来自Linux Land.我曾经在我的这个小Bash函数.bashrc中将一个" shruggie "(¯\_(?)_/¯)复制到剪贴板上,以便我可以将它粘贴到Slack上的对话等等.

我的Bash别名看起来像这样: alias shruggie='printf "¯\_(?)_/¯" | xclip -selection c && echo "¯\_(?)_/¯"'

我意识到这个问题是少年,但答案确实对我有价值,因为我确信我将需要在未来的某个时刻将非UTF-8字符输出到Powershell脚本中输出.

我在PowerShell配置文件中编写了这个函数:

function shruggie() {
  '¯\_(?)_/¯' | clip
  Write-Host '¯\_(?)_/¯ copied to clipboard.' -foregroundcolor yellow
}
Run Code Online (Sandbox Code Playgroud)

但是,当我在命令行上调用它时,这给了我:( ??\_(???)_/??未知的UTF-8字符被转换为?).

我已经查看了[System.Text.Encoding]::UTF8一些其他 问题,但我不知道如何将我的字符串转换为UTF-8并将其传递到clip.exe另一端(在剪贴板上)接收UTF-8.

powershell character-encoding

6
推荐指数
1
解决办法
2149
查看次数

如何在 Windows 上的 Go (golang) 中打印 UTF-8(或 unicode)字符

让我们看看这个:

\n\n
\xe2\x9c\x93 Hello, \xe4\xb8\x96\xe7\x95\x8c\n
Run Code Online (Sandbox Code Playgroud)\n\n

正如您所看到的,有一个 unicode 复选标记和中文/日文字符。在 go 中,如果我使用 MSYS 或 linux 环境,我可以轻松打印这些字符。即使在窗户上。但是,我无法在CMD或 中看到它们Powershell

\n\n

我懂了:

\n\n

电源外壳

\n\n

这是我非常基本的代码:

\n\n
package main\n\nimport (\n    "fmt"\n)\n\nfunc main() {\n\n    fmt.Println("\xe2\x9c\x93 Hello, \xe4\xb8\x96\xe7\x95\x8c")\n    // OR\n    fmt.Println("\\u2713 Hello, \xe4\xb8\x96\xe7\x95\x8c")\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

此外,我有数十个控制台应用程序,它们能够使用 cmd 或 powershell 在我的窗口上显示此类字符。为什么去不了?

\n

console powershell go

6
推荐指数
1
解决办法
1万
查看次数

TeamCity 记录 UTF8 - Powershell 脚本

我创建了 powershell 脚本以在 TeamCity 上的一个步骤中读取文件。如果我在 Powershell 应用程序中读取文件并放置下一个脚本,它可以正常工作,但是当在运行程序类型“PowerShell”的步骤中执行该文件时,编码不起作用并且某些字符没有编码(例如“áãéí”等,等等)

$userDocuments = [environment]::getfolderpath("mydocuments")
$file= "myfile.txt"
$fullPath = Join-Path $userDocuments -ChildPath $file
Get-Content -Encoding UTF8 $fullPath
Run Code Online (Sandbox Code Playgroud)

有人帮我好吗?

提前致谢

powershell teamcity encoding readfile

0
推荐指数
1
解决办法
1086
查看次数