Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1040879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:16:45+00:00 2026-05-16T15:16:45+00:00

I have a problem while trying to batch convert the encoding of some files

  • 0

I have a problem while trying to batch convert the encoding of some files from ISO-8859-1 to UTF-8 using iconv in a powershell script.

I have this bat file, that works ok:

for %%f in (*.txt) do (
  echo %%f
  C:\"Program Files"\GnuWin32\bin\iconv.exe -f iso-8859-1 -t utf-8 %%f > %%f.UTF_8_MSDOS 
)

I need to convert all files on the directories structure, so I programmed this other script, this time using powershell:

Get-ChildItem -Recurse -Include *.java |
  ForEach-Object {
    $inFileName = $_.DirectoryName + '\' + $_.name
    $outFileName = $inFileName + "_UTF_8"
    Write-Host Convirtiendo $inFileName -> $outFileName  
    C:\"Program Files"\GnuWin32\bin\iconv.exe -f iso-8859-1 -t utf-8 $inFileName > $outFileName
  }

And using this the result is the files be converted to UTF-16. I have no clue about what I am doing wrong.

Could anyone help me with this? Could be it some kind of problem with the encoding of powershell itself?

I am using W7 and WXP and LibIconv 1.9.2

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:16:45+00:00Added an answer on May 16, 2026 at 3:16 pm

    > essentially is using the Out-File cmdlet who’s default encoding is Unicode. Try:

    iconv.exe ... | Out-File -Encoding Utf8
    

    or with params:

    & "C:\Program Files\GnuWin32\bin\iconv.exe" -f iso-8859-1 -t utf-8 $inFileName |
       Out-File -Encoding Utf8 $outFileName 
    

    And since iconv.exe is outputting in UTF8, you have to tell the .NET console subsystem how to intrepret the stdin stream like so (execute this before iconv.exe):

    [Console]::OutputEncoding = [Text.Encoding]::UTF8 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some problem while trying to use the schemagen tool from JAXB library
I have a very weird problem while trying to pass and SQL query using
I have a problem while trying to upload using plupload and jquery ui dialog
I have a problem while trying to decrypt encrypted assertion using SAML 2.0. The
I have a problem while trying to save cookies to a file using FileCookieJar
I'm having a strange problem while trying to make a date from some user
I have a strange problem while trying to start JBoss from Eclipse. After starting,
I have this problem I've been trying to tackle for a while. I have
I have been trying to solve this problem for a while, but couldn't with
I have been working on this problem for a while now. I am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.