如何将十六进制字符串转换为十进制? [英] How to convert hexadecimal string to decimal?
本文介绍了如何将十六进制字符串转换为十进制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果您能告诉我如何在 NSString
中转换十六进制字母,例如使用Objective-C将 @50A6C2
改为小数。提前致谢。
I would appreciate it if you could tell me how I can convert hexadecimal letters within an NSString
, e.g. @"50A6C2"
, to decimals using Objective-C. Thanks in advance.
推荐答案
最简单的方法是使用 NSScanner ,特别是方法 scanHexInt:
或 scanHexLongLong:
。另一种可能是从NSString获取C字符串,并使用C风格的函数,如 strtol
(以16为基数)。
The easiest way is to use an NSScanner, specifically the methods scanHexInt:
or scanHexLongLong:
. Another possibility is to get the C string from the NSString and use C-style functions such as strtol
(with base 16).
这篇关于如何将十六进制字符串转换为十进制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文