00:02
HumanG33k has quit [Ping timeout: 260 seconds]
00:03
HumanG33k has joined #crystal-lang
03:58
<
FromGitter >
<djberg96> I seem to have frozen my repl with: `Range.new(" ", "~").to_a`
04:11
ur5us has quit [Ping timeout: 252 seconds]
04:19
<
FromGitter >
<Blacksmoke16> Probably lot of chars between those
07:17
Sankalp- has joined #crystal-lang
07:17
Sankalp has quit [Ping timeout: 264 seconds]
07:17
Sankalp- is now known as Sankalp
09:08
renich has quit [Quit: Leaving]
11:48
irc_user has joined #crystal-lang
12:36
jmdaemon has quit [Ping timeout: 264 seconds]
12:55
<
FromGitter >
<djberg96> should just be 32..126
13:13
<
FromGitter >
<djberg96> `("A".."z").to_a` - same
13:43
<
FromGitter >
<Blacksmoke16> In the interpreter?
13:51
<
FromGitter >
<Blacksmoke16> oh, try doing `('A'..'z').to_a`
13:51
<
FromGitter >
<Blacksmoke16> i.e. `Char` type not `String`
13:53
<
FromGitter >
<Blacksmoke16> seems the string one just isnt performant once you get to special chars
15:26
<
FromGitter >
<djberg96> aha, thanks!
15:30
<
FromGitter >
<djberg96> Is there a crystal equivalent of Ruby's `Enumerable#grep`?
15:31
<
FromGitter >
<Blacksmoke16> is that any diff than `#find`?
15:31
<
FromGitter >
<djberg96> find only finds the first element, doesn't it?
15:31
<
FromGitter >
<Blacksmoke16> okay, `#select` then :P
15:33
<
FromGitter >
<djberg96> yep, that should work, thanks!
15:33
<
FromGitter >
<Blacksmoke16> there's also an overload that accepts a value which does the `===` comparison. super helpful for extracting elements of a specific type or what have you
15:34
<
FromGitter >
<djberg96> fantastic
15:56
taupiqueur has joined #crystal-lang
16:07
irc_user has quit [Quit: Connection closed for inactivity]
17:54
<
rocx >
speaking of ruby methods missing, i did notice integers didn't have a `#between?` method. though that could just simply be `(x..y).includes? z`
17:57
<
FromGitter >
<Blacksmoke16> or prob `x <= z <= y`?
18:08
wwalker has quit [Quit: leaving]
18:08
wwalker has joined #crystal-lang
18:47
<
FromGitter >
<moe:busyloop.net> not a good method to have imho. have to look at the docs to find out if it's inclusive or exclusive.
19:01
irc_user has joined #crystal-lang
19:07
<
FromGitter >
<djberg96> does crystal have the equivalent of `:undef => :replace` for string encoding?
19:07
<
FromGitter >
<Blacksmoke16> hm?
19:10
<
FromGitter >
<djberg96> ok, will try that, thanks
20:08
jmdaemon has joined #crystal-lang
20:19
ur5us has joined #crystal-lang
20:24
jmiven has quit [Quit: reboot]
20:25
jmiven has joined #crystal-lang
20:51
Sankalp has quit [Ping timeout: 252 seconds]
20:51
_ht has joined #crystal-lang
20:58
Sankalp has joined #crystal-lang
21:14
_ht has quit [Remote host closed the connection]
21:28
<
FromGitter >
<djberg96> well, in this case I need to keep the original character count
21:28
<
FromGitter >
<Blacksmoke16> what are you wanting to do?
21:28
<
FromGitter >
<djberg96> there a way to force encode it to US-ASCII?
21:30
<
FromGitter >
<djberg96> I was going to just simulate the `:replace` with `s.bytes.to_a.fill(63, 128..255)` but that gives me an IndexError
21:31
<
FromGitter >
<djberg96> korean text, in this case the bytes are `[237, 149, 156, 234, 181, 173, 236, 150, 180, 236, 157, 152, 32, 235, 130, 180, 236, 154, 169, 235, 182, 132, 236, 132, 157, 236, 157, 132, 32, 236, 156, 132, 237, 149, 156, 10]`
21:31
<
FromGitter >
<djberg96> the idea is that we don't want to accidentally consider that text a binary
21:32
<
FromGitter >
<Blacksmoke16> you can use that encode method to get the bytes of the string in a particular encoding yea
21:33
<
FromGitter >
<Blacksmoke16> tho i dont really follow what this method is doing
21:35
<
FromGitter >
<djberg96> basically it's checking to see if 30 percent or more of the bytes are non-textual
21:35
<
FromGitter >
<Blacksmoke16> oh, by replacing the textual ones with `nil` or something?
21:36
<
FromGitter >
<djberg96> Ruby replaces it with "?"
21:37
<
FromGitter >
<djberg96> or “uFFFD” depending
21:37
<
FromGitter >
<Blacksmoke16> thats essentially what `#scrub` does
21:37
<
FromGitter >
<Blacksmoke16> but you can change the char to be `?` if you wanted
21:40
<
FromGitter >
<djberg96> scrub only works if the bytes are invalid UTF-8
21:41
<
FromGitter >
<Blacksmoke16> ah okay, yea then `str.encode "US-ASCII", :skip` then compare the size from before/after?
21:42
<
FromGitter >
<djberg96> guess i could do that :)
21:43
<
FromGitter >
<djberg96> I need an overloaded version of scrub that let's me set the encoding to check against :)
21:45
<
FromGitter >
<Blacksmoke16> idk how Ruby does it, but all strings in Crystal are UTF-8, so thats prob the reasoning for that
21:45
<
FromGitter >
<Blacksmoke16> can work with other encodings via bytes, but not as strings themselves
21:47
<
FromGitter >
<djberg96> why doesn't this work? `[237, 149, 63, 63, 181, 173, 236, 150, 180, 236, 157, 152, 32, 235, 130, 180, 236, 154, 169, 235, 182, 132, 236, 132, 157, 236, 157, 132, 32, 236, 156, 132, 237, 149, 156, 10].fill(63, 128..255)`
21:47
<
FromGitter >
<djberg96> idea here was to replace anything 128+ with 63 ("?").
21:49
<
FromGitter >
<Blacksmoke16> im not sure `#fill` is what you want?
21:49
<
FromGitter >
<Blacksmoke16> you prob want `#map!`?
21:52
<
FromGitter >
<djberg96> ok, will do that, thanks
23:30
hightower2 has joined #crystal-lang
23:33
hightower2 has quit [Remote host closed the connection]
23:34
hightower2 has joined #crystal-lang
23:37
Starfoxxes has quit [Ping timeout: 248 seconds]