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

The Archive Base Latest Questions

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

I currently get a string as a parameters in my method, i would like

  • 0

I currently get a string as a parameters in my method,
i would like to extract the char in the I index and get it’s hex value.
Currently i’m doing :

temp = string[i]
binascii.hexlify(temp);

but i get an error :

TypeError: 'str' does not support the buffer interface

Any ideas please ?

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

    You need to encode the string to bytes:

    binascii.hexlify(temp.encode('ascii'));
    

    You’ll need to pick a suitable encoding, one that can represent your text properly; I am presuming that your unicode characters fall in the 0-127 range here.

    If you encode to a different encoding, the result will be a hex representation of that encoding. UTF-8 will use between 1 and 6 bytes per character for example.

    Alternatively, you could use the ord() function and format the result to hex:

    format(ord(temp), 'x')
    

    and it’ll work with any unicode character. It’ll use the Unicode code point for the hex representation, so between 1 and 4 bytes (the latter for \Uabcdefgh wide characters). Depending on your maximum character width, you may want to pad the bytes to prevent ambiguous code points; say you need to encode up to codepoint \uffff then you’ll need to use 2 bytes for every codepoint, or 4 hex characters:

    format(ord(temp), '04x')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to get the address string of the current user location. Is
Currently I have this: [SomeCustomAttribute] public string Name { get; set; } However, I
I currently have the following Get-ChildItem -recurse -include file.ext | Select-String -pattern c: |
I would like to override Url.Content to append a query string parameter to the
I am currently passing a parameter to a SQL string like this - grid=0&
i would like to convert a method that already does the job (only if
I'm currently trying to get into Java Web Development in general in Spring more
Unsure how to get this string to work correctly. Keeps making my page blank.
Beside query string root folder how do i get the current doc library list(ListName)
I'm trying to get the query string from a string (not the current URL).

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.