| View previous topic :: View next topic |
| Author |
Message |
Raccoon
Joined: 02 Jan 2008 Posts: 70 Location: Freenode IRC
|
Posted: Tue Mar 11, 2008 10:05 am Post subject: |
|
|
Actually, I'm interested in this function because I'd like to modify it to use an arbitrary character table. Base 46 including all URL compatible "non-reserved' characters including the symbols " - _ . ! ~ * ' ( )
Consider how TinyURL or YouTube urls are constructed, but utilizing all of the valid symbols in a lookup table. _________________ Need help right away? Get live support on IRC.
Already have an IRC client installed? /join #autohotkey |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4032 Location: Pittsburgh
|
Posted: Tue Mar 11, 2008 2:07 pm Post subject: |
|
|
It is still just two lines for unsigned numbers | Code: | ToBase(n,b) { ; n >= 0, 1 < b < StrLen(t), t = digits
Static t := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmnopqrstuvwxyz{|}~"
Return (n < b ? "" : ToBase(n//b,b)) . SubStr(t,mod(n,b)+1,1)
} | Change the static variable t to contain your desired digits in order. |
|
| Back to top |
|
 |
heresy
Joined: 11 Mar 2008 Posts: 291
|
Posted: Wed May 14, 2008 3:27 pm Post subject: |
|
|
OMG! Laszlo you rock!!!
i never imagine that base conversion can be done in just one line
totally amazing  _________________ Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com |
|
| Back to top |
|
 |
Guest
|
Posted: Thu May 15, 2008 2:54 am Post subject: |
|
|
| heresy wrote: | | i never imagine that base conversion can be done in just one line |
It's just a translation of the elementary school routine you're already familiar with. You must have a relatively deep understanding of AHK to figure it out though. |
|
| Back to top |
|
 |
|