Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #7323

How to properly backslash-escape string in Ruby.

From niemda <niemda@me.com>
Newsgroups comp.lang.ruby
Subject How to properly backslash-escape string in Ruby.
Date 2017-01-04 18:47 +0000
Organization news.babsi.de for www.open-news-network.org
Message-ID <slrno6qgmi.490.niemda@thinkpad.local> (permalink)

Show all headers | View raw


Hello, 

How do I properly convert ruby string into backslash-escaped string? The
source is base64-encoded value and result should be escaped, so some
charaters must be encoded as '\xnn'. 

Example: 
Input is 'tracking@c3BlYw==.service' and expected result 
is 'tracking@c3BlYw\x3d\x3d.service'.

I've already invented the wheel by hacking some conversion routine to do
this and tried eval (not in production code, the problem mainly exists
in specs).

-- 
Vladimir
There is no matter where you are, everyone is connected

Back to comp.lang.ruby | Previous | NextNext in thread | Find similar


Thread

How to properly backslash-escape string in Ruby. niemda <niemda@me.com> - 2017-01-04 18:47 +0000
  Re: How to properly backslash-escape string in Ruby. Robert Klemme <shortcutter@googlemail.com> - 2017-01-04 23:19 +0100

csiph-web