The Archives
-
06.11.10hex2bin preserving endianness in CI cannot help copying this snippet. Assume f is a (char *) of length L, containing an hex string like '0aabdda' (without the leading "0x", like something coming from a sha function ---or like the sha1 stored by Leopard in the password files, which is the origin of this problem). You want to transform it into the corresponding sequence of bytes (that is, assuming the string is of even length, otherwise, we add a trailing, yes, trailing, at the end, '0'). We shall store the result in t, which points to a (char *) of length L/2. The following C code ...
-
02.16.09Perl for accents and spaces in html hrefsDespite the title looking like spam, it uses all the relevant keywords in a problem which I guess is more common than it looks like, especially in non-English speaking countries. I had created (automatically, not by hand) a set of html, pdf and rtf files of the 477 items of a regional catalogue of industrial estate (sorry, no references because it belongs to other people and they have not published it yet). Then I made the index.html page listing and linking to all those files. It looked like a list of lines like the following one (notice that what follows looks ...
-
11.15.08Strings in bashStart with a string: $ a="hi, this is my beautifull string" Positional substrings: Substring from the 4th character on: $ echo ${a:3} this is my beautifull string Substring of length 4 from the 10th character: $ echo ${a:9:4} is m Substring modification: Substitute the first instance of a substring: $ echo ${a/full/ful} hi, this is my beautiful string Same example: $ echo ${a/h/H} Hi, this is my beautifull string Substitute all the instances of a substring: $ echo ${a//hi/HI} HI, tHIs is my beautifull string Substring removal: Remove the shortest match of a substring from the start: $ echo ${a#h*i} , this is my beautifull string Same, starting at the end $ echo ${a%i*g} hi, this is my beautifull str Remove the longest match of a ...