Git Product home page Git Product logo

Comments (3)

rkeithhill avatar rkeithhill commented on July 21, 2024

PowerShell/.NET typically does a good job of detecting the encoding of text files before it converts them to Unicode strings for processing inside PowerShell. However, when writing those Unicode strings out to a file, the user should be able to specify if they want another encoding - typically UTF8 or UTF8-NoBOM.

from plaster.

LaurentDardenne avatar LaurentDardenne commented on July 21, 2024

Ok, but this implies a upstream control :

$t=@(
 "Default",
 "Ascii",
 "BigEndianUnicode",
 "BigEndianUTF32",
 "Oem",
 "Unicode",
 "UTF32",
 "UTF7",
 "UTF8"
)

$t|% {
     Write-Warning "Encoding :  $PSItem"
  @'
  #encoding test 
  $i=10
  $échec=$true

  Write "test : à é ï ù Ô" 
  10 -eq $i
  $échec -eq $true
'@ |Set-content -path C:\Temp\TestEncoding.ps1 -encoding $PSItem
  gc "C:\Temp\TestEncoding.ps1"   
  &"C:\Temp\TestEncoding.ps1"
}

Is it possible to change the default encoding value for all files (create/copy/modify) ?

from plaster.

rkeithhill avatar rkeithhill commented on July 21, 2024

Copy should not mess with encoding - the file may be a dll. For template expansion and modify, the default is the PowerShell default for Set-Content which is ASCII IIRC.

from plaster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.