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 8638831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:50:25+00:00 2026-06-12T10:50:25+00:00

Possible Duplicate: How do I convert files between encodings where only some of them

  • 0

Possible Duplicate:
How do I convert files between encodings where only some of them are wrong?

I use the following command to convert .srt files from windows-1250 to utf-8 from a folder

for /f "delims=" %%a IN (' dir C:\utf_check\*.srt /b /s ') do %iconv% -s -f windows-1250 -t utf-8 < %%a > %%a.txt

I have a problem with this, if the file is already utf-8, iconv breaks the file inserting strange characters. Is there a way to detect first if is utf-8 or ascii then convert it? I tried with flip, enca, encov, recode with no success.

I use Windows 2003 Server, I installed Cygwin too, maybe that would help.

Example: that is the text found in a utf-8 Aşezaţi-vă.
and this is the text after iconv is converting again AĹźezaĹŁi-vÄ.

  • 1 1 Answer
  • 0 Views
  • 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-06-12T10:50:26+00:00Added an answer on June 12, 2026 at 10:50 am

    No sensible text in windows-1250 encoding will ever be valid utf-8. Because the bytes representing characters beyond ASCII range in utf-8 correspond to sequences of characters in windows-1250 that make no sense. So you need to first check whether the file is valid utf-8 and only if it is not, do the conversion.

    You can use the fact, that iconv fails (with errorlevel 1) if it can’t do the conversion. So you first run iconv -f utf-8 -t utf-8 and if it fails, run iconv -f windows-1250 -t utf-8.

    Note, that this works only for deciding whether something is utf-8 or legacy encoding but you can’t tell between various legacy encodings, because the range of valid characters are the same or mostly so for all windows-anything encodings, so you’d have to do some more advanced heuristics, probably involving spell-checker.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Convert from char* to NSString? I have char myChar = 'r' How
Possible Duplicate: Tool to convert python indentation from spaces to tabs? I have a
Possible Duplicate: Code convert from C++ to C Converting a C++ class to a
Possible Duplicate: convert string to nsdate The NSString has following value '2012-07-11T15:59:16' I am
Possible Duplicate: convert string to integer in c++ Convert a no. from string to
Possible Duplicate: Convert string to Pascal Case (aka UpperCamelCase) in Javascript I'm doing some
Possible Duplicate: How do I compare strings in Java? I read some records from
Possible Duplicate: Convert a number to the shortest possible character string while retaining uniqueness
Possible Duplicate: How to convert a factor to an integer\numeric without a loss of
Possible Duplicate: How to convert MDB to SQLite in Android I have an MS

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.