Jump to content

Is alnum ASCII only?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
kenna

kenna

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
Is isalnum ASCII only (locale independent) or does is return true for any character of any locale?

I'm trying to write a short program that converts a binary file into an escaped string that can be included in a source file, thus I need to escape everything not /{0~9a~zA~Z}/.

e.g. static char image = "[converted data goes here]";

Also, is char always 8 bits, or are there platforms where it changes? and is there a simple way of implementing portable data type sizes (not only char).

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Depending on your environment, you may not be dealing with ASCII at all. C/C++ works just as well with EBCDIC and other character encodings. You would need to check with your compiler documentation to see if there is any locale information involved.

Similarly, the number of bits a char can store is implementation dependent, depending on your hardware architecture, OS, and compiler.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog