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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:37:06+00:00 2026-06-06T10:37:06+00:00

I have a string in Python 2.7.2 say u\u0638. When I write it to

  • 0

I have a string in Python 2.7.2 say u”\u0638″.
When I write it to file:

f = open("J:\\111.txt", "w+")
f.write(u"\u0638".encode('utf-16'))
f.close()

In hex it looks like: FF FE 38 06
When i print such a string to stdout i will see: ‘\xff\xfe8\x06’.

The querstion: Where is \x38 in the string output to stdout? In other words why the string output to stdout is not ‘\xff\xfe\x38\x06’?

If I write the string to file twice:

f = open("J:\\111.txt", "w+")
f.write(u"\u0638".encode('utf-16'))
f.write(u"\u0638".encode('utf-16'))
f.close()

The hex representation in file contains byte order mark (BOM) \xff\xfe twice: FF FE 38 06 FF FE 38 06

I wonder what is the techique to avoid writting BOM in UTF-16 encoded strings?

  • 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-06T10:37:08+00:00Added an answer on June 6, 2026 at 10:37 am

    The ASCII character 8 has hex representation 0x38. So your string:

    \xff\xfe8\x06
    

    is four bytes long. Separated by spaces, the bytes are:

    \xff \xfe 8 \x06
    

    Python uses the \x notation for bytes that do not represent printable ASCII characters.

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

Sidebar

Related Questions

Say I have a string in Python 3.2 like this: '\n' When I print()
Say I have a string that looks like this: str = The &yquick &cbrown
Let's say I have a standard Python string (such as one obtained from raw_input()
Say that I have the Python code: someString = file(filename.jpg).read() How can I replicate
Ok say I have a string in python: str=martin added 1 new photo to
In Python, say I have a string that contains the name of a class
i have string stored in python variables, and i am outputting a html that
I have some code in a python string that contains extraneous empty lines. I
I have a string in the format: 'nn.nnnnn' in Python, and I'd like to
I am using Python 2.7 . I have an alphanumeric string, on which 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.