IRC channel logs

2018-04-10.log

back to list of logs

***gour_ is now known as gour
<civodul>hey hey!
<rain1>hello :)
***fibratio` is now known as fibration
<Labu>hello guile
<rain1>hi
<Labu>I'am looking for a function which allows to replace arbitrary substring by another
<Labu>example: (string-replace "zzxxaaxx" "xx" "aa") -> "zzaaaaaa"
<Labu>I have looked in the documentation and I found nothing which fit with my needs
<Labu>so I made my function
<Labu>but I don't be really satisfied
<Labu> https://pastebin.com/deBjUYL0
<Labu>like this
<daviid>Labu: fwiw, I would use regexp-substitute/global (ice-9 regex)
<daviid>like this
<Labu>hi daviid indeed regex
<Labu>it's better
<Labu>thx
<daviid>(define (string-replace-all str search-for replace-by)
<daviid> (regexp-substitute/global #f search-for str 'pre replace-by 'post))
<Labu>thx daviid
<daviid>wc!
<rain1>that seems wrong
<rain1>what if 'search-for' contains any characters that regex interprets
<daviid>string-replace-all expects strings, not regexp, but you could write another procedure, picking another name, that would ... feel free
<rain1>for example (string-replace-all "zz.*aa.*" ".**" "aa") should return "zzaaaaaa" but it returns "aa"
<daviid>as i said, it hasn't been written to solve the above, it expects strings
<rain1>those are string
<rain1>(string? ".*") = #t
<daviid>ah, i wrote this 2 decades ago, patch welcome ...
<daviid>probably guix has a good tested str replace [all] procedure
<rain1>ah, i was checking srfi 13 and it doesn't seem to have it
<daviid>guix has string-replace-substring
<daviid>with a test suite ...
<rain1>that seems like a good function to move into guile itself
<daviid>in guix/utils.scm
<daviid>Labu: here - http://git.savannah.gnu.org/cgit/guix.git/tree/guix/utils.scm - starts line 548 ... voilà!
<daviid>I would call it string-replace-all though but ...
<rain1>yeah I prefer the name string-replace-all
<Labu>thx daviid
<Labu>right now I fight against encoding problems
<Labu>I don't know yet If it comes from curl with I test my API or the lib I am using to parse input
<amz3>héllo all
<Labu>hi amz3 !
<spk121>OK. Let's make the Guile 2.2.x work on MinGW.
<amz3>^^
<OrangeShark>hello
<manumanumanu>hello
<Labu>I get strange behaviour I can't explain. I am usin a web-server in a program wich I launch with run-server. If I get (port-encoding (current-output-port)) before launch the server I have UTF-8 encoding but in a handler pass to this server I have ASCII. Have I miss something to specify in run-server to get the correct encoding for stdout ?
<amz3>Labu: did you call (setlocale LC_ALL "") ?
<Labu>no amz3
<Labu>but
<amz3>maybe it will help
<Labu>(display (setlocale LC_ALL))(newline)
<Labu>give me C
<Labu>it's strange because my locale are UTF-8 on my terminal
<Labu>I try this
<Labu>thx
<Labu>amz3 It works
<Labu>but why ?
<amz3>i don't remember read the doc about setlocale
<Labu>ok thx
<Labu>ok thx amz3
<Labu>I have just reading the documentation about this
<Labu>(setlocale LC_ALL "") initialize all categories based on standard environment
<Labu>thx
<amz3>tx