1

I am currently trying to make my Ruby script output the following:

"\x41" * 28 "\x42\x13\x40\x00"

My code is:

puts "\x41" * 28 "\x42\x13\x40\x00"

instead of outputting it as you might expect it outputs: AAAAAAAAAAAAAAAAAAAAAAAAAAAAB‼@

I know that this is the "translated" values but how do I avoid this translation? I have been looking into .pack() but I could not figure it out.

Thanks in advance.

Dar56

1 Answer 1

4

How about

puts "\\x41" * 28 + "\\x42\\x13\\x40\\x00"

or

puts '\x41' * 28 + '\x42\x13\x40\x00'

Case 1 works because \\ is an escape sequence meaning a \ while case 2 works because the literals inside '' only check for the \' and \\ escape sequences.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.