Jump to content
  • Advertisement

Collage

Member
  • Content count

    1
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Collage

  • Rank
    Newbie
  1. Collage

    signed/unsigned char

    Folks, im just learning c++, havent got too far yet but i've come upon a peculiarity with signed/unsigned char*'s. Say I have an unsigned char*: unsigned char buf1[]="José"; (unsigned because of the extended character 'é', which is ascii code 233 unless placed in a signed char in which case it is "wrapped around" to -23) I want to copy it to another buffer: unsigned char buf2[32]; strcpy(buf2,buf1); the above does not work because strcpy expects char*'s not unsigned char*'s. It will work however if cast them to char*'s i.e. strcpy((char*)buf2,(char*)buf1); is this safe? Will my extended character come out as the correct 233 acsii code or the "wrapped round" -23 code? If this will cause problems how would I store my list as unsigned char*'s and copy between them? In case anyone is wondering, the reason I need the extended characters to retain their correct ascii code is because _toupper will not work if they end up wrapped around i.e. ascii code for é is 233 when put in an unsigned char, _toupper('é') correctly capitalises the letter. When put in a signed char 'é' ends up as -23 and _toupper leaves it alone and does not capitalise it. Thanks for the help.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!