相关疑难解决方法(0)

如何在不更改编码的情况下将命令的输出传输到文件?

我想将命令的输出通过管道传输到文件:

PS C:\Temp> create-png > binary.png
Run Code Online (Sandbox Code Playgroud)

我注意到 Powershell 更改了编码,并且我可以手动给出编码:

PS C:\Temp> create-png | Out-File "binary.png" -Encoding OEM
Run Code Online (Sandbox Code Playgroud)

然而,没有 RAW 编码选项,即使 OEM 选项也会将换行字节 ( 0xAresp 0xD) 更改为 Windows 换行字节序列 ( 0xD 0xA),从而破坏任何二进制格式。

如何防止 Powershell 在管道传输到文件时更改编码?

相关问题

powershell encoding pipeline pipe

4
推荐指数
1
解决办法
2774
查看次数

Go 生成的动画 GIF 在 Windows 中不起作用

我发现一个示例在 Windows 中无法正常工作。该程序演示了 Go 标准图像包的基本用法,我们将使用它来创建位图图像序列,然后将该序列编码为 GIF 动画。

package main

import (
    "image"
    "image/color"
    "image/gif"
    "io"
    "math"
    "math/rand"
    "os"
)

import (
    "log"
    "net/http"
    "time"
)

//!+main

var palette = []color.Color{color.White, color.Black}

const (
    whiteIndex = 0 // first color in palette
    blackIndex = 1 // next color in palette
)

func main() {
    //!-main
    // The sequence of images is deterministic unless we seed
    // the pseudo-random number generator using the current time.
    // Thanks to Randall McPherson for pointing …
Run Code Online (Sandbox Code Playgroud)

image file gif go

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

标签 统计

encoding ×1

file ×1

gif ×1

go ×1

image ×1

pipe ×1

pipeline ×1

powershell ×1