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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:23:52+00:00 2026-05-26T23:23:52+00:00

Does character set encoding affects the result of strstr() function? For example, I have

  • 0

Does character set encoding affects the result of strstr() function?

For example, I have read a data to “buf” and do this:

char *p = strstr (buf, "UNB");

I wonder whether the data is encoded in ASCII or others (e.g. EBCDIC) affects the result of this function?
(Since “UNB” are different bit streams under different encoding ways…)

If yes, what’s the default that is used for these function? (ASCII?)

Thanks!

  • 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-05-26T23:23:52+00:00Added an answer on May 26, 2026 at 11:23 pm

    The C functions like strstr operate on the raw char data,
    independently of the encoding. In this case, you potentially have two
    different encodings: the one the compiler used for the string literal,
    and the one your program used when filling buf. If these aren’t the
    same, then the function may not work as expected.

    With regards to the “default” encoding, there isn’t one, at least as far
    as the standard is concerned; the ”basic execution character
    set“ is implementation defined. In practice, systems which don’t
    use an encoding derived from ASCII (ISO 8859-1 seems the most common, at
    least here in Europe) are exceedingly rare. As for the encoding you get
    in buf, that depends on where the characters come from; if you’re
    reading from an istream, it depends on the locale imbued in the
    stream. In practice, however, again, almost all of these (UTF-8,
    ISO8859-x, etc.) are derived from ASCII, and are identical with ASCII
    for all of the characters in the basic execution character set
    (which includes all of the characters legal in traditional C). So for
    "UNB", you’re likely safe. (but for something like "üéâ", you almost
    certainly aren’t.)

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

Sidebar

Related Questions

Does anybody know if there is a simple way to detect character set encoding
In Java is there a way to check the condition: Does this single character
Does anyone have a method to overcome the 260 character limit of the MSBuild
Does SQL Server's (2000) Soundex function work on Asian character sets ? I used
Does Lua provide a function to make the first character in a word uppercase
why does this code crash? is using strcat illegal on character pointers? #include <stdio.h>
Is a string actually a character array (is-a), or does it have a character
I'm looking for functional way to set default character encoding for HTTP responses for
Does anyone know what the character entity for a tab is in xhtml? (Um
How does one compare single character strings in Perl? Right now, I'm tryin to

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.