Log In  

Cart #46393 | 2017-11-17 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

Char Utility Fns is a non-playable cartridge with some utility functions for categorizing and manipulating character strings, including conversion to and from string characters, and numeric code points. It also has tolower(), totitle(), and toupper() functions to take advantage of the lower-case (well... small caps) letters that are available in the PICO-8 font, but which may not be typed in cartridge source code.

This project was primarily for my own education, and also theoretically for use as a library of useful char-manipulation functions... but since it takes up almost 400 tokens on its own, it'd be a fairly costly library, especially if you don't have need for all the facilities provided. Still, it could be edited down to include just the parts you want to use in a game. I think being able to print title-case messages is particularly neat; I might think about creating a version that only provides the tolower(), totitle() functions, since that was the main thing I was interested in while creating this.

As a curiosity, the source code also demonstrates some advanced function techniques; notably, the use of a top-level, anonymous function to contain/hide some local values - and local functions - that are used to construct some of the actual functions that are exported globally. (The same technique is quite common in many popular JavaScript code libraries.)

P#46394 2017-11-16 20:45 ( Edited 2017-11-17 01:45)


[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-05-31 06:17 | 0.015s | 2097k | Q:26