Board logo

标题: [问题求助] PowerShell怎么读写utf32编码的文件?[已解决] [打印本页]

作者: czjt1234    时间: 2023-1-3 09:06     标题: PowerShell怎么读写utf32编码的文件?[已解决]

本帖最后由 czjt1234 于 2023-1-4 20:04 编辑

http://bbs.bathome.net/thread-64814-1-1.html
这里8楼
原来ps可以读写utf32编码的文件
  1. a1江苏
  2. b2上海
  3. c3浙江
  4. d4河南
  5. e5陕西
复制代码
比如我要把这个字符串以utf32LE编码写入1.txt
然后读取1.txt


请问该怎么写?
作者: WHY    时间: 2023-1-4 15:15

https://learn.microsoft.com/zh-c ... ean-system-boolean)
  1. $str = @'
  2. a1江苏
  3. b2上海
  4. c3浙江
  5. d4河南
  6. e5陕西
  7. '@
  8. $UTF32LE = New-Object System.Text.UTf32Encoding $false, $true;
  9. [IO.File]::WriteAllText('1.txt', $str, $UTF32LE);
  10. $str2 = [IO.File]::ReadAllText('1.txt', $UTF32LE);  
  11. $str2;
  12. [Console]::ReadLine();
复制代码





欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2