ORDCHR(3am)
π ORDCHR π
okay bestie, welcome to ordchr(3am) β it's part of the GNU Awk Extension Modules family, and honestly? it's giving tiny-but-mighty. β¨
β¨ NAME β¨
ordchr β the girl who converts characters to strings and vice versa π
β¨ SYNOPSIS β¨
@load "ordchr"
number = ord("A")
string = chr(65)
β¨ DESCRIPTION β¨
so the ordchr extension drops two functions into your gawk life: ord() and chr(). that's it, that's the whole vibe. here's the tea on each:
ord()β you hand her a string argument, she hands you back the numeric value of the first character</... wait, no, just the first character's numeric value. and if the conversion goes sideways? she returns-1. no drama, just-1. πchr()β you hand her a numeric argument, she returns a string whose first character is the one represented by that number. conversion error? you get the empty string. nothing. void. silence. π«Ά
these functions are inspired by the Pascal language functions of the same name, which is lowkey iconic of them. π
πΈ NOTES πΈ
as of release 5.4 of gawk, these functions support wide-character code points. periodt. π
π EXAMPLE π
@load "ordchr"
...
printf("The numeric value of 'A' is %d\n", ord("A"))
printf("The string value of 65 is %s\n", chr(65))
literally that's the whole demo and it ate. π₯
π¦ SEE ALSO π¦
GAWK: Effective AWK Programming, and the man pages for the other extensions shipped with gawk. go read them, they're all besties. π
π AUTHOR π
Arnold Robbins, arnold@skeeve.com. π
π COPYING PERMISSIONS π
Copyright Β© 2012, 2013, 2018, 2025, 2026, Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this manual page provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual page under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Foundation.
ngl bestie, this page is from the Free Software Foundation, dated Feb 25 2026, and it's filed under ORDCHR(3am). mwah, slay, bye. πβ¨π
π¦ where this page comes from
- arch rolling: gawk 5.4.1-1 Β· GPL-3.0-or-later
- nixos 26.05: gawk-interactive 5.4.1
- nixpkgs unstable: gawk 5.4.1
- nixpkgs unstable: gawk-interactive 5.4.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms