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

  • SEARCH
  • Home
  • 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 9012187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:56:00+00:00 2026-06-16T02:56:00+00:00

I have a PLC application that requires the Unicode format of UTF-16LE to support

  • 0

I have a PLC application that requires the Unicode format of UTF-16LE to support accented characters. I build the text and convert it with:

str = Iconv.conv("utf-16le", "utf-8", str)

Then I output the file with the following:

send_data str, :filename => "sp_table.txt", :type => 'text/plain; charset=utf-16le; header=present;', :disposition => 'attachment'

The PLC application is not able to display the characters. If I read the file type properties with file -I, I get the following:

sp_table.txt: application/octet-stream; charset=binary

If I open the file in Notepad in Windows, it displays correctly. If I resave the file through Notepad, selecting Unicode as the encoding, file -I returns:

sp_table.txt: text/plain; charset=utf-16le

Also, after saving through Notepad, I am able to correctly display all characters in the PLC application.

Should I be specifying a different charset when I send the file?

  • 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-16T02:56:01+00:00Added an answer on June 16, 2026 at 2:56 am

    Notepad adds a BOM, whereas UTF-16LE doesn’t. I am bit iffy on the ruby syntax, but something like this:

    str = Iconv.conv("utf-16le", "utf-8", "\ufeff" + str)
    

    Or

    str = "\xFF\xFE" + Iconv.conv("utf-16le", "utf-8", str)
    

    Or

    str = "\377\376" + Iconv.conv("utf-16le", "utf-8", str)
    

    Basically the idea is to add the bytes 0xFF 0xFE (BOM for Little Endian UTF-16) at the beginning before sending them.

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

Sidebar

Related Questions

I have WPF C# application that communicate with a PLC (i.e. write/read Omron PLC's
i have an C# application that is writing status information from a PLC device,
Have an app that can use tts to read text messages. It can also
I have an application that takes voltages and temperatures as analog inputs and does
I am developing a device that will continuously collect data from a PLC and
Have a form here with bunch of input text fields and a file upload
Have a simple form that has a PictureBox in one location. I want to
I have upgraded from gevent 13.x to 1.0b4. I have Failover code that checks
Currently I have multiple resources in a project that can only be accessed from
I would like to be able to communicated with PLC controllers, so that I

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.