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.

Path csiph.com!2.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!news.roellig-ltd.de!news.babsi.de!open-news-network.org!news2.open-news-network.org!.POSTED!not-for-mail
From niemda <niemda@me.com>
Newsgroups comp.lang.ruby
Subject How to properly backslash-escape string in Ruby.
Date Wed, 4 Jan 2017 18:47:25 +0000 (UTC)
Organization news.babsi.de for www.open-news-network.org
Lines 17
Message-ID <slrno6qgmi.490.niemda@thinkpad.local> (permalink)
Reply-To niemda <niemda@me.com>
NNTP-Posting-Host pool-77-222-115-88.is74.ru
X-Trace news2.open-news-network.org 1483555645 2923 77.222.115.88 (4 Jan 2017 18:47:25 GMT)
X-Complaints-To abuse@open-news-network.org
NNTP-Posting-Date Wed, 4 Jan 2017 18:47:25 +0000 (UTC)
User-Agent slrn/1.0.2 (Linux)
Xref csiph.com comp.lang.ruby:7323

Show key headers only | 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