Convert numbers to letters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phub11
    New Member
    • Feb 2008
    • 127

    Convert numbers to letters

    Hi all,

    I was wondering if there is a quick way to convert numbers to letters, such as 1=A, and 26=Z. I can do it the laborious way using 26 definitions, but it's always nice to know of any shortcuts!

    Thanks
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    you can use the character’s Unicode value.
    Code:
    // A is #65 in Unicode
    String.fromCharCode(64+x);

    Comment

    • phub11
      New Member
      • Feb 2008
      • 127

      #3
      I guess that will convert it to UniCode, shift it across 64 members of the character set, and then convert it back.

      Thanks!

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        Originally posted by phub11
        I guess that will convert it to UniCode, shift it across 64 members of the character set, and then convert it back.
        not really, you put in a number (2) and get a letter back (B). (U+0002 is a control character)

        Comment

        Working...