4 ms·
My boss recently asked me to write a couple of very simple Python scripts for mobile translations. I had to convert files to replace 𞉀 type sequences int
by b0rsuk 8y ago
My boss recently asked me to write a couple of very simple Python scripts for mobile translations. I had to convert files to replace 𞉀 type sequences into proper UTF-8 codepoints. I had to replace a bunch of unicode codepoints with a mirrored en-us side. I had to convert lines like "abc" = "def"; into a trivial .json file (a single flat dictionary).
The task was very simple in Python, but would be absolutely trivial and fun in AWK if it
a) had first class unicode support, including conversion
b) had a support for quoted fields. I think it needs a new variable, like QC (Quote Character) of FD (Field Delimiter).
I would put money on a kickstarter of another crowdfunding initiative to modernize AWK. I don't mean by slapping a Python or other programming language on it, but by fishing long-standing issues with it. I think a for loop like in Python, Rust and VimL would be a better fit to an otherwise simple language (only C-style fors are available in BEGIN/END).
- hawski 8y agoWhat do you mean by C-style for? for (key in array) is POSIX. I miss in awk mainly a structural regular expressions mode. With it I would not miss lack of structures or that functions like gsub do not return a string instead of assigning it to a variable.
- b0rsuk 8y agoI mean for(x=0;x<10;x++). This stands out like a sore thumb in a language famous for its brevity and frictionless syntax. There should be a better way.
- n4r9 8y agoDon't know about the original awk but in gnu awk you have simpler for loops. https://www.gnu.org/software/gawk/manual/html_node/Scanning-an-Array.html https://www.gnu.org/software/gawk/manual/html_node/Scanning-...