XCode base_convert

China☆狼群 提交于 2019-12-11 05:08:49

问题


I am developing iOS application and I need base_convert function. Application is communicating with PHP server using base_convert, too. In PHP I use this:

base_convert($something,16,36) and base_convert($something,36,16)

I search for something like I use in PHP, but for Xcode (iOS application). Thank you.


回答1:


there is a C++ implementation here:

http://thinkdiff.net/mixed/base-conversion-handle-upto-36-bases/

that will convert back and forth with bases up to 36. Not sure if you need more than that.




回答2:


There is a complete wikepedia page devoted to Base 36 with various forms of source code that you could adapt (for example the C code should just drop straight in with no modification but is soooo not objective-c)

There is also how to convert Decimal to base36 which only does a one-way conversion, but the code is objective-c, so you could get an idea on how to adapt the wikepedia code.

As to why base 36 I learnt:

Base 36 is therefore the most compact case-insensitive alphanumeric numeral system using ASCII characters




回答3:


Adapted the code David Hope suggested into Objective-C, here:

https://gist.github.com/furkanmustafa/5660086



来源:https://stackoverflow.com/questions/14613548/xcode-base-convert

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!