![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Text with special characters or Encoding Hi, I'm having trouble with scripts which parses text from a file where the text contains special characters (norwegian/scandinavian). Any tips on how to make sure PS reads these correctly? -Eivind Brenningen Senior IT Consultant |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Text with special characters or Encoding Hi, and thanks! Unfortunately this didn't change anything. I'm trying to manipulate AD user objects, but usernames with norwegian characters always have these replaced by other characters (ie. ø (oe) is replaced by ?). The input is read from a csv-file. -- -Eivind Brenningen Senior IT Consultant "Shay Levi" wrote: Quote: > > > Hi Eivind, > > I found three culture names for Norwegian, so choose which one to use: > > PS 5> $cultures = [System.Globalization.CultureInfo]::GetCultures("AllCultures") > PS 6> $cultures| where {$_.DisplayName -match "norwe"} | select Name,DisplayName > > > Name DisplayName > ---- ----------- > no Norwegian > nb-NO Norwegian, Bokm?l (Norway) > nn-NO Norwegian, Nynorsk (Norway) > > > > > This is the script, comments inline: > > > $newCulture = "nn-NO" > $scriptBlock = { ... put your code here ... } > > # get the original culture > $orgCulture = [System.Threading.Thread]::CurrentThread.CurrentUICulture > > # apply new culture > [System.Threading.Thread]::CurrentThread.CurrentUICulture = $newCulture > [System.Threading.Thread]::CurrentThread.CurrentCulture = $newCulture > > # execute scriptblock code > & $scriptBlock > > # restore original culture > [System.Threading.Thread]::CurrentThread.CurrentUICulture = $orgCulture > [System.Threading.Thread]::CurrentThread.CurrentCulture = $orgCulture > > > > > --- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > Quote: > > Hi, > > > > I'm having trouble with scripts which parses text from a file where > > the text contains special characters (norwegian/scandinavian). Any > > tips on how to make sure PS reads these correctly? > > > > -Eivind Brenningen > > Senior IT Consultant > > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Text with special characters or Encoding Hi Eivind, I found three culture names for Norwegian, so choose which one to use: PS 5> $cultures = [System.Globalization.CultureInfo]::GetCultures("AllCultures") PS 6> $cultures| where {$_.DisplayName -match "norwe"} | select Name,DisplayName Name DisplayName ---- ----------- no Norwegian nb-NO Norwegian, Bokm?l (Norway) nn-NO Norwegian, Nynorsk (Norway) This is the script, comments inline: $newCulture = "nn-NO" $scriptBlock = { ... put your code here ... } # get the original culture $orgCulture = [System.Threading.Thread]::CurrentThread.CurrentUICulture # apply new culture [System.Threading.Thread]::CurrentThread.CurrentUICulture = $newCulture [System.Threading.Thread]::CurrentThread.CurrentCulture = $newCulture # execute scriptblock code & $scriptBlock # restore original culture [System.Threading.Thread]::CurrentThread.CurrentUICulture = $orgCulture [System.Threading.Thread]::CurrentThread.CurrentCulture = $orgCulture --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > Hi, > > I'm having trouble with scripts which parses text from a file where > the text contains special characters (norwegian/scandinavian). Any > tips on how to make sure PS reads these correctly? > > -Eivind Brenningen > Senior IT Consultant |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Text with special characters or Encoding What version of PowerShell do you use? CTP2 can handle 'culture-aware' CSV files. --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > Hi, and thanks! > > Unfortunately this didn't change anything. > > I'm trying to manipulate AD user objects, but usernames with norwegian > characters always have these replaced by other characters (ie. ? (oe) > is replaced by ?). The input is read from a csv-file. > > "Shay Levi" wrote: > Quote: >> Hi Eivind, >> >> I found three culture names for Norwegian, so choose which one to >> use: >> >> PS 5> $cultures = >> [System.Globalization.CultureInfo]::GetCultures("AllCultures") PS 6> >> $cultures| where {$_.DisplayName -match "norwe"} | select >> Name,DisplayName >> >> Name DisplayName >> ---- ----------- >> no Norwegian >> nb-NO Norwegian, Bokm?l (Norway) >> nn-NO Norwegian, Nynorsk (Norway) >> This is the script, comments inline: >> >> $newCulture = "nn-NO" >> $scriptBlock = { ... put your code here ... } >> # get the original culture >> $orgCulture = >> [System.Threading.Thread]::CurrentThread.CurrentUICulture >> # apply new culture >> [System.Threading.Thread]::CurrentThread.CurrentUICulture = >> $newCulture [System.Threading.Thread]::CurrentThread.CurrentCulture = >> $newCulture >> >> # execute scriptblock code >> & $scriptBlock >> # restore original culture >> [System.Threading.Thread]::CurrentThread.CurrentUICulture = >> $orgCulture [System.Threading.Thread]::CurrentThread.CurrentCulture = >> $orgCulture >> >> --- >> Shay Levi >> $cript Fanatic >> http://scriptolog.blogspot.com Quote: >>> Hi, >>> >>> I'm having trouble with scripts which parses text from a file where >>> the text contains special characters (norwegian/scandinavian). Any >>> tips on how to make sure PS reads these correctly? >>> >>> -Eivind Brenningen >>> Senior IT Consultant |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Text with special characters or Encoding Create a copy of the original CSV with Unicode or UTF8 encoding and test it. sc .\copy.csv (gc .\original.csv) -en unicode # test it ipcsv .\copy.csv -- Kiron |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Text with special characters or Encoding Is powershell running under the norwegian/scandinavian regional settings? --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > What version of PowerShell do you use? CTP2 can handle 'culture-aware' > CSV files. > > --- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com Quote: >> Hi, and thanks! >> >> Unfortunately this didn't change anything. >> >> I'm trying to manipulate AD user objects, but usernames with >> norwegian characters always have these replaced by other characters >> (ie. ? (oe) is replaced by ?). The input is read from a csv-file. >> >> "Shay Levi" wrote: >> Quote: >>> Hi Eivind, >>> >>> I found three culture names for Norwegian, so choose which one to >>> use: >>> >>> PS 5> $cultures = >>> [System.Globalization.CultureInfo]::GetCultures("AllCultures") PS 6> >>> $cultures| where {$_.DisplayName -match "norwe"} | select >>> Name,DisplayName >>> >>> Name DisplayName >>> ---- ----------- >>> no Norwegian >>> nb-NO Norwegian, Bokm?l (Norway) >>> nn-NO Norwegian, Nynorsk (Norway) >>> This is the script, comments inline: >>> $newCulture = "nn-NO" >>> $scriptBlock = { ... put your code here ... } >>> # get the original culture >>> $orgCulture = >>> [System.Threading.Thread]::CurrentThread.CurrentUICulture >>> # apply new culture >>> [System.Threading.Thread]::CurrentThread.CurrentUICulture = >>> $newCulture [System.Threading.Thread]::CurrentThread.CurrentCulture >>> = >>> $newCulture >>> # execute scriptblock code >>> & $scriptBlock >>> # restore original culture >>> [System.Threading.Thread]::CurrentThread.CurrentUICulture = >>> $orgCulture [System.Threading.Thread]::CurrentThread.CurrentCulture >>> = >>> $orgCulture >>> --- >>> Shay Levi >>> $cript Fanatic >>> http://scriptolog.blogspot.com >>>> Hi, >>>> >>>> I'm having trouble with scripts which parses text from a file where >>>> the text contains special characters (norwegian/scandinavian). Any >>>> tips on how to make sure PS reads these correctly? >>>> >>>> -Eivind Brenningen >>>> Senior IT Consultant |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Text with special characters or Encoding That did the trick! Thank you both. -- -Eivind Brenningen Senior IT Consultant "Kiron" wrote: Quote: > Create a copy of the original CSV with Unicode or UTF8 encoding and test > it. > > sc .\copy.csv (gc .\original.csv) -en unicode > > # test it > ipcsv .\copy.csv > > -- > Kiron > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Using special characters on my tagline | Live Messenger | |||
| Password with special characters | Live Mail | |||
| Typing in special characters bug | Vista General | |||
| Special Characters - how? | Vista General | |||
| How to run program with special characters | PowerShell | |||