# Fastest way to remove this strange character

**URL:** <https://www.ruby-forum.com/t/fastest-way-to-remove-this-strange-character/124227>\
**Category:** Ruby\
**Created:** [December 26, 2007, 7:20pm UTC](https://www.ruby-forum.com/t/fastest-way-to-remove-this-strange-character/124227 "2007-12-26T19:20:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [December 26, 2007, 7:20pm UTC](https://www.ruby-forum.com/t/fastest-way-to-remove-this-strange-character/124227/1 "2007-12-26T19:20:45Z")

</div>

Hello  
I was trying out the roo gem and encountered this issue. when i do a  
object.sheets, it seems to spit out the array and adds \000 for every  
letter of the sheet name  
for eg.  
currentTrade becomes c\000u\000r\000r\000e\000n\000t\000T\000r\000a  
\000d\000e\000

which is the fastest way to remove \000 from the array.

irb(main):005:0\> ss=Excel.new(“E:\Documents and Settings\TTSSR0149  
\Desktop\orderingsystem.xls”)

irb(main):003:0\> ss.sheets()  
=\> [“c\000u\000r\000r\000e\000n\000t\000T\000r\000a\000d\000e\000”, “M  
\000i\000s  
\000s\000e\000d\000T\000r\000a\000d\000e\000”, “S\000c\000a\000n\000s  
\000”, “c\0  
00l\000o\000s\000e\000d\000”]  
irb(main):004:0\>

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [December 26, 2007, 7:36pm UTC](https://www.ruby-forum.com/t/fastest-way-to-remove-this-strange-character/124227/2 "2007-12-26T19:36:33Z")

</div>

quoth the Junkone:

> Hello  
> I was trying out the roo gem and encountered this issue. when i do a  
> object.sheets, it seems to spit out the array and adds \000 for every  
> letter of the sheet name  
> for eg.  
> currentTrade becomes c\000u\000r\000r\000e\000n\000t\000T\000r\000a  
> \000d\000e\000
> 
> which is the fastest way to remove \000 from the array.

irb\> s = “c\000u\000r\000r\000e\000n\000t\000T\000r\000a\000d\000e\000”  
irb\> n = “”  
irb\> s.unpack(“S\*”).each {|c| n \<\< c.chr}  
=\> [99, 117, 114, 114, 101, 110, 116, 84, 114, 97, 100, 101]  
irb\> n  
=\> “currentTrade”

Not sure if this is fastest or ‘best’…

-d

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [December 27, 2007, 12:34am UTC](https://www.ruby-forum.com/t/fastest-way-to-remove-this-strange-character/124227/3 "2007-12-27T00:34:20Z")

</div>

On Dec 26, 2007 7:20 PM, Junkone [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> irb(main):004:0\>  
> It’s unicode - so you may use iconv to convert to whatever 8-bit  
> encoding you want.  
> If you want to have the ‘fastest’ one - compare it to other approaches  
> with Benchmark.
