XCode base_convert

2019-08-12 10:26发布

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.

3条回答
三岁会撩人
2楼-- · 2019-08-12 10:59

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

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

查看更多
Summer. ? 凉城
3楼-- · 2019-08-12 11:11

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.

查看更多
再贱就再见
4楼-- · 2019-08-12 11:15

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

查看更多
登录 后发表回答