Windows Vista Forums

how do i get locales in sync between powershell and dotnet

  1. #1


    Harald Ums \(2179630\) Guest

    how do i get locales in sync between powershell and dotnet

    on a german pc:
    PS C:\Temp> [double]::Parse("12.3")
    123
    PS C:\Temp> [double]"12.3"
    12,3



    extremely unpleasant to debug such errors ...

    Harald

      My System SpecsSystem Spec

  2. #2


    dreeschkind Guest

    RE: how do i get locales in sync between powershell and dotnet

    PS> $nfi = new-object System.Globalization.NumberFormatInfo
    PS> $nfi.NumberDecimalSeparator = ','
    PS> [double]::Parse('3,1415', $nfi)
    3,1415

    --
    greetings (from Germany)
    dreeschkind

    "Harald Ums (2179630)" wrote:

    > on a german pc:
    > PS C:\Temp> [double]::Parse("12.3")
    > 123
    > PS C:\Temp> [double]"12.3"
    > 12,3
    >
    > extremely unpleasant to debug such errors ...
    >
    > Harald
    >


      My System SpecsSystem Spec

  3. #3


    dreeschkind Guest

    RE: how do i get locales in sync between powershell and dotnet

    This should also work:

    PS> $bratwurst = new-object System.Globalization.CultureInfo "de-DE"
    PS> [double]::Parse('0,815', $bratwurst)
    0,815

    --
    greetings
    dreeschkind

    "dreeschkind" wrote:

    > PS> $nfi = new-object System.Globalization.NumberFormatInfo
    > PS> $nfi.NumberDecimalSeparator = ','
    > PS> [double]::Parse('3,1415', $nfi)
    > 3,1415
    >
    > --
    > greetings (from Germany)
    > dreeschkind
    >
    > "Harald Ums (2179630)" wrote:
    >
    > > on a german pc:
    > > PS C:\Temp> [double]::Parse("12.3")
    > > 123
    > > PS C:\Temp> [double]"12.3"
    > > 12,3
    > >
    > > extremely unpleasant to debug such errors ...
    > >
    > > Harald
    > >


      My System SpecsSystem Spec

  4. #4


    Maximilian Hänel Guest

    Re: how do i get locales in sync between powershell and dotnet

    Hi dreeschkind,

    or if one prefers one-liners:

    PS> [Double]::Parse('0,815', [Globalization.CultureInfo]'de-DE')
    0,815

    cu

    Max

      My System SpecsSystem Spec

  5. #5


    Harald Ums \(2179630\) Guest

    Re: how do i get locales in sync between powershell and dotnet


    I hoped there is something like LC_LOCALE=C and everything would be handled
    in the invariant locale.
    It is not the problem to change one or two statements, but to get a reliable
    environment, that gives the same results independend of who runs the skript.

    "Maximilian Hänel" <ngSpam@smjh.de> wrote in message
    news:%23zhDLcFtHHA.4796@TK2MSFTNGP04.phx.gbl...
    > Hi dreeschkind,
    >
    > or if one prefers one-liners:
    >
    > PS> [Double]::Parse('0,815', [Globalization.CultureInfo]'de-DE')
    > 0,815
    >
    > cu
    >
    > Max



      My System SpecsSystem Spec

how do i get locales in sync between powershell and dotnet

Similar Threads
Thread Thread Starter Forum Replies Last Post
dotnet DLL im IE Tobias Bergmann .NET General 0 20 Oct 2009
Beginner - which is best dotnet.VB or dotnet.VC? SteveB .NET General 6 07 Sep 2008
Dotnet 2.0 RG .NET General 4 16 May 2008
Powershell and different dotnet versions Whisperer PowerShell 4 15 Sep 2007
Powershell and sync data Cyber-Guy PowerShell 11 05 Sep 2007