简体   繁体   English

将扩展字符转换为int

[英]Convert Extended characters to int

I have the following string in notepad "ùŒÚÿwž+2»ó66H". 我在记事本“ùŒÚÿwž+ 2»ó66H”中有以下字符串。

I used the fstream library to read those files in c++ and print those characters and thier equivalent decimal numbers in the conlsole window but the symbols are different than those in notepad and numbers for the extended characters are in negative form,i realize maybe its impossible for my console window to print those symbols as the vary through many character sets but how do i get the numbers displayed as 255 and not -1 ?? 我使用fstream库读取c ++中的那些文件,并在conlsole窗口中打印了这些字符和等价的十进制数字,但是这些符号与记事本中的符号不​​同,并且扩展字符的数字为负数,我意识到对于我的控制台窗口将这些符号打印为许多字符集之间的差异,但是如何获取显示为255而不是-1的数字?

Simple version: Read the file as unsigned char instead of char and use printf('%c', a) to see what character you get. 简单版本:将文件读取为unsigned char而不是char然后使用printf('%c', a)来查看得到的字符。 This will get you values between 0 to 255 and not -128 to 127 这将为您提供0到255之间的值,而不是-128到127之间的值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM