Activity Graph

Page 1 of 1


[21:43:04] renlolo: has joined #ruby
[21:43:58] renlolo: I have this string, literally, `\"` ... how do I convert this to the literal string `\\"` , this is very frustrating as I keep getting `\\\"` instead, which is not what I want (I do not want " to be escaped)
[21:48:26] renlolo: in memory I should have `\"`, what's getting printed is `\\\"` ... is there any way to convert this to `\\"` in the memory representation (or `\\\\"`)
[21:54:11] renlolo: let me put it this way, I have two bytes `\"` (forget ruby for a moment). i want three bytes, `\\"`. How do I do this in ruby, regardless of how it's printed
[21:56:14] renlolo: &> '\"'.bytesize
[21:56:26] renlolo: &>> '\"'.bytesize
[21:56:43] renlolo: &>> '\"'.sub('\"', '\\\\"').bytesize
[21:57:29] renlolo: cool, but sub isnt working for some reason with that
[21:57:59] renlolo: &>> '\"'.sub('\"', '\\\"').bytesize
[21:59:44] renlolo: sorry, why what?
[22:01:16] renlolo: I'm not a ruby expert (used to python, heh), but we're using fluentd for log aggregation. My fluentd plugin is receiving strings which are exactly `\"`, but when I try to encode them I get some error saying that it's an invalid escape, which is a valid error, because `\"` is an invalid escape. I'd therefore want to forward `\\"` instead ... which is where I am
[22:05:52] renlolo: hmm, thanks for pointing that out
[22:08:07] renlolo: so I probably want to replace '\\"' with '\\\\"'
[22:10:34] renlolo: so '\"', is [\, "] in memory, and '\\"' is also [\, "] in memory?
[22:13:00] renlolo: I still cant get it to work for some reason ...
[22:13:21] renlolo: &>> '\"'.sub('\"', '\\\\"').bytesize
[22:13:42] renlolo: '\\\\"' should be [\, \, "] right?
[22:14:12] renlolo: I've tried it with `"` as well, "\\\""
[22:18:43] renlolo: &>> a='\"'.gsub('\\', '\\\\\\').bytesize # looks like it works
[22:19:15] renlolo: why there are 6 backslashes in the substitution I dont know but yeah
[22:19:26] renlolo: #trialanderror
[23:15:45] renlolo: so gsub('\\', '\\\\\\') doesnt work ...
[23:16:17] renlolo: this is honestly pretty frustrating, I think I'll actively push towards us moving away from ruby. Thanks for your help all, have a good one
[23:16:25] renlolo: has left #ruby: ("WeeChat 2.0.1")