Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About Collage

  • Rank
  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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!