I had a "file.txt" with this string and to show the special characters and then replace
my file.txt
https://drive.google.com/file/d/1pTh4rxdlmA3Qq0aVwF5jCTK3StqXrQeJ/view?usp=sharing
12,IBA�EZ JUAN,2006,00030,NUEVO
the character � I know is a "Ñ"
I want this
12,IBAÑEZ JUAN,2006,00030,NUEVO
i have tried
tr '\0xd1' 'Ñ' < file.txt > file_2.txt
my xxd is
$ hexdump -C file.txt
00000000 31 32 2c 49 42 41 ef bf bd 45 5a 20 4a 55 41 4e |12,IBA...EZ JUAN|
00000010 2c 32 30 30 36 2c 30 30 30 33 30 2c 4e 55 45 56 |,2006,00030,NUEV|
00000020 4f 2c 00 2c 20 20 20 20 20 20 20 20 20 20 2c 4e |O,., ,N|
00000030 4f 2c 00 2c 30 30 36 2c 50 2c 37 2e 30 30 30 2c |O,.,006,P,7.000,|
00000040 2e 30 30 30 2c 31 32 2e 37 34 2c 2e 30 30 30 2c |.000,12.74,.000,|
00000050 2d 2c 32 30 30 36 2d 30 36 2d 33 30 |-,2006-06-30|
0000005c
Using hexdump, we find that my file is deferring from yours with 3 redundant bytes at the very start.
cat file.txt | hexdump -C
12,IBA�EZ JUAN,2006,00030,NUEVO, , ,NO, ,006,P,7.000,.000,12.74,.000,-,2006-06-30
Piping the cat output onto tr command,
cat file.txt | tr -s "�" "Ñ"
$ cat file.txt | hexdump -C
00000000 ef bb bf 31 32 2c 49 42 41 ef bf bd 45 5a 20 4a |...12,IBA...EZ J|
00000010 55 41 4e 2c 32 30 30 36 2c 30 30 30 33 30 2c 4e |UAN,2006,00030,N|
00000020 55 45 56 4f 2c 20 2c 20 20 20 20 20 20 20 20 20 |UEVO, , |
00000030 20 2c 4e 4f 2c 20 2c 30 30 36 2c 50 2c 37 2e 30 | ,NO, ,006,P,7.0|
00000040 30 30 2c 2e 30 30 30 2c 31 32 2e 37 34 2c 2e 30 |00,.000,12.74,.0|
00000050 30 30 2c 2d 2c 32 30 30 36 2d 30 36 2d 33 30 |00,-,2006-06-30|
0000005f
Again, check for hexdump to check the changes if you want.The original text had 3 unprintable characters which are now replaced by 2 characters: Ñ . Check the screenshot below:
terminal-session
Related
I'm trying to correctly parse an ISO8583(1987) message in Python 3 using the py8583 package. After running into some issues with the parser I've realized that the bitmap in the ISO8583 message seems to not be formatted correctly.
This is the ISO8583 bitmap in question:
P8P1211661684989
This is the entire ISO8583 message. It's using trash test data so don't need to worry about sensitive info.
NP0100P8P1211661684989300000000000002004914104019041104009904SHDPf406c431Cashier_01 01301001000200491665D9832B92FD380C
From what I understand the bitmap should only contain 1-9/A-F hex characters, yet as you can see it begins with "P8P12...".
Is there something I'm missing here? These ISO8583 messages are currently being used within an enterprise-level company. Additionally, while some online parsers throw the bitmap error, I've found one that seems to be parsing it just fine (link below). I can't figure out how it's doing the parsing.
http://www.fintrnmsgtool.com/decode-iso87-bitmap.html
(Edit: It was correctly pointed out by glhr that this site doesn't allow you to type non-hex characters, only copy/paste them, so it's probably no longer relevant to the question.)
Hex dump below:
0010 08 00 45 00 00 ab 03 b1 00 00 3c 06 fa 89 c0 a8
0020 15 02 40 87 69 e1 81 1c 0b bb b7 b9 78 55 c7 86
0030 4a 2c 50 18 12 24 2f d3 00 00 4e 50 00 00 00 7d
0040 30 31 30 30 50 38 00 01 80 c0 00 50 31 32 31 31
0050 36 36 31 36 38 34 39 38 39 33 30 30 30 30 30 30
0060 30 30 30 30 30 30 30 32 30 30 34 38 31 34 30 39
0070 35 39 31 39 30 34 31 31 30 34 30 30 39 39 30 34
0080 53 48 44 50 66 34 30 36 63 34 33 31 43 61 73 68
0090 69 65 72 5f 30 31 20 20 20 20 20 30 31 33 30 31
00a0 30 30 31 30 30 30 32 30 30 34 38 31 36 36 35 44
00b0 39 38 33 32 42 39 32 46 44 33 38 30 43
Any help from ISO8583 experts would be greatly appreciated!
Something seems amiss.
From the hex dump it looks like some kind of 0800 network message. That would make the bitmap starting with 0x45. This would be a binary bitmap of 0100 0101, indicating bits 2, 6, and 8 are present. ISO 8583 bit 2 is always a PAN (card number), so that does not make much sense. Bit's 6 and 8 don't seem to make sense in the context of a network message either as the former is cardholder billing amount, and the latter is cardholder amount fee.
So, here is something I want to do;
binary_string_data_input = '00 AE 65 67 32 2F 33 3A 54 20 46'
and I want to insert the following bytes BETWEEN the string like this:
binary_string_data_output = '00 AE 65 67 **55 06 33 55 FF** 32 2F 33 3A 54 20 46'
Help would be much appreciated thanks!
You can split (or slice) to get the first part:
>>> string_data_input[:12]
'00 AE 65 67 '
and similarly the last part:
>>> string_data_input[12:]
'32 2F 33 3A 54 20 46'
So, you can join these with your new "inner" part:
>>> string_data_input[:12] + '55 06 33 55 FF ' + string_data_input[12:]
'00 AE 65 67 55 06 33 55 FF 32 2F 33 3A 54 20 46'
This question already has answers here:
How to remove ^[, and all of the escape sequences in a file using linux shell scripting
(14 answers)
Closed 4 years ago.
I have a file on a Linux machine which contains many hidden characters which are as follows :
$ cat -v file.txt
^[[2J^[[?7l^[[3;23r^[[?6l^[[1;1H^[[?25l^[[1;1HLogging into the device
Software revision V1.0
Copyright All Rights Reserved.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions
ABC, COMPANY
^[[1;24r^[[1;1H^[[44;1HPress any key to continue^[[44;1H^[[?
25h^[[44;27H^[[2J^[[?7l^[[1;24r^[[?
6l^[[44;27H^[[1;44r^[[44;1H^[[44;1H^[[2K^[[44;1H^[[?25h^[[44;1H^[[44;1HMH
5 percent busy, from 388 sec ago
1 sec ave: 4 percent busy
5 sec ave: 16 percent busy
1 min ave: 7 percent busy
^[[1;44r^[[44;1H^[[44;1H^[[2K^[[44;1H^[[?25h^[[44;1H^[[44;1My-Device-SW>
^[[44;1H^[[44;11H^[[44;1H^[[?
25h^[[44;11H^[[44;0H^[E^[[44;1H^[[44;11H^[[44;1H^[[2K^[[44;1H^[[?.
Earlier there were some ^M characters which I removed using :
sed 's/^M//g' file.txt
I want to remove only the hidden characters so that my actual file looks like :
$ cat file.txt
Logging into the device
Software revision V1.0
Copyright All Rights Reserved.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions
ABC, COMPANY
Press any key to continue
My-Device-SW>
My-Device-show CPU
5 percent busy, from 388 sec ago
1 sec ave: 4 percent busy
5 sec ave: 16 percent busy
1 min ave: 7 percent busy
My-Device-SW>
My-Device-exit
Do you want to log out [y/n]? y
Connection to My-Device-SW closed.
Also posting the output of hexdump -C file.txt :
$ hexdump -C file.txt
00000000 1b 5b 32 4a 1b 5b 3f 37 6c 1b 5b 33 3b 32 33 72 |.[2J.[?7l.[3;23r|
00000010 1b 5b 3f 36 6c 1b 5b 31 3b 31 48 1b 5b 3f 32 35 |.[?6l.[1;1H.[?25|
00000020 6c 1b 5b 31 3b 31 48 4c 6f 67 67 69 6e 67 20 69 |l.[1;1HLogging i|
00000030 6e 74 6f 20 74 68 65 20 64 65 76 69 63 65 0a 53 |nto the device.S|
00000040 6f 66 74 77 61 72 65 20 72 65 76 69 73 69 6f 6e |oftware revision|
00000050 20 56 31 2e 30 0a 43 6f 70 79 72 69 67 68 74 20 | V1.0.Copyright |
00000060 41 6c 6c 20 52 69 67 68 74 73 20 52 65 73 65 72 |All Rights Reser|
00000070 76 65 64 2e 0a 20 20 20 20 20 20 20 20 20 20 20 |ved.. |
00000080 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
00000090 52 45 53 54 52 49 43 54 45 44 20 52 49 47 48 54 |RESTRICTED RIGHT|
000000a0 53 20 4c 45 47 45 4e 44 0a 20 55 73 65 2c 20 64 |S LEGEND. Use, d|
000000b0 75 70 6c 69 63 61 74 69 6f 6e 2c 20 6f 72 20 64 |uplication, or d|
000000c0 69 73 63 6c 6f 73 75 72 65 20 62 79 20 74 68 65 |isclosure by the|
000000d0 20 47 6f 76 65 72 6e 6d 65 6e 74 20 69 73 20 73 | Government is s|
000000e0 75 62 6a 65 63 74 20 74 6f 20 72 65 73 74 72 69 |ubject to restri|
000000f0 63 74 69 6f 6e 73 0a 20 20 20 20 20 20 20 20 20 |ctions. |
00000100 41 42 43 2c 20 43 4f 4d 50 41 4e 59 0a 1b 5b 31 |ABC, COMPANY..[1|
00000110 3b 32 34 72 1b 5b 31 3b 31 48 1b 5b 34 34 3b 31 |;24r.[1;1H.[44;1|
00000120 48 50 72 65 73 73 20 61 6e 79 20 6b 65 79 20 74 |HPress any key t|
00000130 6f 20 63 6f 6e 74 69 6e 75 65 1b 5b 34 34 3b 31 |o continue.[44;1|
00000140 48 1b 5b 3f 32 35 68 1b 5b 34 34 3b 32 37 48 1b |H.[?25h.[44;27H.|
00000150 5b 32 4a 1b 5b 3f 37 6c 1b 5b 31 3b 32 34 72 1b |[2J.[?7l.[1;24r.|
00000160 5b 3f 36 6c 1b 5b 34 34 3b 32 37 48 1b 5b 31 3b |[?6l.[44;27H.[1;|
00000170 34 34 72 1b 5b 34 34 3b 31 48 1b 5b 34 34 3b 31 |44r.[44;1H.[44;1|
00000180 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 1b 5b 3f 32 |H.[2K.[44;1H.[?2|
00000190 35 68 1b 5b 34 34 3b 31 48 1b 5b 34 34 3b 31 48 |5h.[44;1H.[44;1H|
000001a0 4d 79 2d 44 65 76 69 63 65 2d 53 57 3e 20 1b 5b |My-Device-SW> .[|
000001b0 34 34 3b 31 48 1b 5b 34 34 3b 31 31 48 1b 5b 34 |44;1H.[44;11H.[4|
000001c0 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b 34 34 3b 31 |4;1H.[?25h.[44;1|
000001d0 31 48 1b 5b 34 34 3b 30 48 1b 45 1b 5b 34 34 3b |1H.[44;0H.E.[44;|
000001e0 31 48 1b 5b 34 34 3b 31 31 48 1b 5b 34 34 3b 31 |1H.[44;11H.[44;1|
000001f0 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 1b 5b 3f 32 |H.[2K.[44;1H.[?2|
00000200 35 68 1b 5b 34 34 3b 31 48 1b 5b 31 3b 34 34 72 |5h.[44;1H.[1;44r|
00000210 1b 5b 34 34 3b 31 48 1b 5b 31 3b 34 34 72 1b 5b |.[44;1H.[1;44r.[|
00000220 34 34 3b 31 48 1b 5b 34 34 3b 31 48 1b 5b 32 4b |44;1H.[44;1H.[2K|
00000230 1b 5b 34 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b 34 |.[44;1H.[?25h.[4|
00000240 34 3b 31 48 1b 5b 34 34 3b 31 48 4d 79 2d 44 65 |4;1H.[44;1HMy-De|
00000250 76 69 63 65 2d 53 57 3e 20 1b 5b 34 34 3b 31 48 |vice-SW> .[44;1H|
00000260 1b 5b 34 34 3b 31 31 48 1b 5b 34 34 3b 31 48 1b |.[44;11H.[44;1H.|
00000270 5b 3f 32 35 68 1b 5b 34 34 3b 31 31 48 1b 5b 34 |[?25h.[44;11H.[4|
00000280 34 3b 31 31 48 73 68 6f 77 20 43 50 55 1b 5b 34 |4;11Hshow CPU.[4|
00000290 34 3b 31 31 48 1b 5b 3f 32 35 68 1b 5b 34 34 3b |4;11H.[?25h.[44;|
000002a0 31 39 48 1b 5b 34 34 3b 30 48 1b 45 1b 5b 34 34 |19H.[44;0H.E.[44|
000002b0 3b 31 48 1b 5b 34 34 3b 31 39 48 1b 5b 34 34 3b |;1H.[44;19H.[44;|
000002c0 31 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 1b 5b 3f |1H.[2K.[44;1H.[?|
000002d0 32 35 68 1b 5b 34 34 3b 31 48 1b 5b 31 3b 34 34 |25h.[44;1H.[1;44|
000002e0 72 1b 5b 34 34 3b 31 48 0a 35 20 70 65 72 63 65 |r.[44;1H.5 perce|
000002f0 6e 74 20 62 75 73 79 2c 20 66 72 6f 6d 20 33 38 |nt busy, from 38|
00000300 38 20 73 65 63 20 61 67 6f 0a 31 20 73 65 63 20 |8 sec ago.1 sec |
00000310 61 76 65 3a 20 34 20 70 65 72 63 65 6e 74 20 62 |ave: 4 percent b|
00000320 75 73 79 0a 35 20 73 65 63 20 61 76 65 3a 20 31 |usy.5 sec ave: 1|
00000330 36 20 70 65 72 63 65 6e 74 20 62 75 73 79 0a 31 |6 percent busy.1|
00000340 20 6d 69 6e 20 61 76 65 3a 20 37 20 70 65 72 63 | min ave: 7 perc|
00000350 65 6e 74 20 62 75 73 79 0a 1b 5b 31 3b 34 34 72 |ent busy..[1;44r|
00000360 1b 5b 34 34 3b 31 48 1b 5b 34 34 3b 31 48 1b 5b |.[44;1H.[44;1H.[|
00000370 32 4b 1b 5b 34 34 3b 31 48 1b 5b 3f 32 35 68 1b |2K.[44;1H.[?25h.|
00000380 5b 34 34 3b 31 48 1b 5b 34 34 3b 31 4d 79 2d 44 |[44;1H.[44;1My-D|
00000390 65 76 69 63 65 2d 53 57 3e 20 1b 5b 34 34 3b 31 |evice-SW> .[44;1|
000003a0 48 1b 5b 34 34 3b 31 31 48 1b 5b 34 34 3b 31 48 |H.[44;11H.[44;1H|
000003b0 1b 5b 3f 32 35 68 1b 5b 34 34 3b 31 31 48 1b 5b |.[?25h.[44;11H.[|
000003c0 34 34 3b 30 48 1b 45 1b 5b 34 34 3b 31 48 1b 5b |44;0H.E.[44;1H.[|
000003d0 34 34 3b 31 31 48 1b 5b 34 34 3b 31 48 1b 5b 32 |44;11H.[44;1H.[2|
000003e0 4b 1b 5b 34 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b |K.[44;1H.[?25h.[|
000003f0 34 34 3b 31 48 1b 5b 31 3b 34 34 72 1b 5b 34 34 |44;1H.[1;44r.[44|
00000400 3b 31 48 1b 5b 31 3b 34 34 72 1b 5b 34 34 3b 31 |;1H.[1;44r.[44;1|
00000410 48 1b 5b 34 34 3b 31 48 1b 5b 32 4b 1b 5b 34 34 |H.[44;1H.[2K.[44|
00000420 3b 31 48 1b 5b 3f 32 35 68 1b 5b 34 34 3b 31 48 |;1H.[?25h.[44;1H|
00000430 1b 5b 34 34 3b 31 48 4d 79 2d 44 65 76 69 63 65 |.[44;1HMy-Device|
00000440 2d 53 57 3e 20 1b 5b 34 34 3b 31 48 1b 5b 34 34 |-SW> .[44;1H.[44|
00000450 3b 31 31 48 1b 5b 34 34 3b 31 48 1b 5b 3f 32 35 |;11H.[44;1H.[?25|
00000460 68 1b 5b 34 34 3b 31 31 48 1b 5b 34 34 3b 31 31 |h.[44;11H.[44;11|
00000470 48 65 78 69 74 1b 5b 34 34 3b 31 31 48 1b 5b 3f |Hexit.[44;11H.[?|
00000480 32 35 68 1b 5b 34 34 3b 31 35 48 1b 5b 34 34 3b |25h.[44;15H.[44;|
00000490 30 48 1b 45 1b 5b 34 34 3b 31 48 1b 5b 34 34 3b |0H.E.[44;1H.[44;|
000004a0 31 35 48 1b 5b 34 34 3b 31 48 1b 5b 32 4b 1b 5b |15H.[44;1H.[2K.[|
000004b0 34 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b 34 34 3b |44;1H.[?25h.[44;|
000004c0 31 48 1b 5b 31 3b 34 34 72 1b 5b 34 34 3b 31 48 |1H.[1;44r.[44;1H|
000004d0 1b 5b 31 3b 34 34 72 1b 5b 34 34 3b 31 48 1b 5b |.[1;44r.[44;1H.[|
000004e0 34 34 3b 31 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 |44;1H.[2K.[44;1H|
000004f0 1b 5b 3f 32 35 68 1b 5b 34 34 3b 31 48 1b 5b 34 |.[?25h.[44;1H.[4|
00000500 34 3b 31 48 44 6f 20 79 6f 75 20 77 61 6e 74 20 |4;1HDo you want |
00000510 74 6f 20 6c 6f 67 20 6f 75 74 20 5b 79 2f 6e 5d |to log out [y/n]|
00000520 3f 20 1b 5b 34 34 3b 31 48 1b 5b 34 34 3b 33 31 |? .[44;1H.[44;31|
00000530 48 1b 5b 34 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b |H.[44;1H.[?25h.[|
00000540 34 34 3b 33 31 48 1b 5b 34 34 3b 33 31 48 79 1b |44;31H.[44;31Hy.|
00000550 5b 34 34 3b 33 31 48 1b 5b 3f 32 35 68 1b 5b 34 |[44;31H.[?25h.[4|
00000560 34 3b 33 32 48 1b 5b 34 34 3b 30 48 1b 45 1b 5b |4;32H.[44;0H.E.[|
00000570 34 34 3b 31 48 1b 5b 34 34 3b 33 32 48 1b 5b 34 |44;1H.[44;32H.[4|
00000580 34 3b 31 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 1b |4;1H.[2K.[44;1H.|
00000590 5b 3f 32 35 68 1b 5b 34 34 3b 31 48 1b 5b 31 3b |[?25h.[44;1H.[1;|
000005a0 34 34 72 1b 5b 34 34 3b 31 48 1b 5b 32 4a 1b 5b |44r.[44;1H.[2J.[|
000005b0 3f 37 6c 1b 5b 31 3b 34 34 72 1b 5b 3f 36 6c 1b |?7l.[1;44r.[?6l.|
000005c0 5b 34 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b 34 34 |[44;1H.[?25h.[44|
000005d0 3b 31 48 1b 5b 3f 36 6c 1b 5b 31 3b 30 72 1b 5b |;1H.[?6l.[1;0r.[|
000005e0 3f 37 6c 1b 5b 32 4a 1b 5b 34 34 3b 31 48 1b 5b |?7l.[2J.[44;1H.[|
000005f0 31 3b 31 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 43 |1;1H.[2K.[44;1HC|
00000600 6f 6e 6e 65 63 74 69 6f 6e 20 74 6f 20 4d 79 2d |onnection to My-|
00000610 44 65 76 69 63 65 2d 53 57 20 63 6c 6f 73 65 64 |Device-SW closed|
00000620 2e 0a |..|
00000622
Can someone please help me out in this?
Modifying with the actual file content above.
Are you using text files created under windows on Linux?. In that case you must install "tofrodos" package in your Linux distro, and then use "fromdos" tool to convert files from windows to linux format:
$ fromdos <windows-file-format.txt>
I have a file with what I believe to be a unicode type and would like to remove them with sed or some other unix utility. I have tried few options and for some reason unable to remove those characters. Test cases shown with single line (head -n1)
Attempt 1:
> head -n1 file1.txt | hexdump -C # Hexdump line 1
output:
00000000 47 72 6f 75 70 c2 a0 20 20 20 53 69 67 6e 61 6c |Group.. Signal|
00000010 c2 a0 6e 61 6d 65 c2 a0 20 20 20 20 20 20 20 20 |..name.. |
00000020 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
00000030 55 6e 69 74 c2 a0 20 74 79 70 65 c2 a0 44 65 73 |Unit.. type..Des|
00000040 63 72 69 70 74 69 6f 6e c2 a0 0d 0a |cription....|
0000004c
Now replace "c2 a0" above
> head -n1 file1.txt | sed 's/\xc2\xa0//g' | hexdump -C
or
> head -n1 file1.txt | sed 's/\x{c2a0}//g | hexdump -C
00000000 47 72 6f 75 70 c2 a0 20 20 20 53 69 67 6e 61 6c |Group.. Signal|
00000010 c2 a0 6e 61 6d 65 c2 a0 20 20 20 20 20 20 20 20 |..name.. |
00000020 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
00000030 55 6e 69 74 c2 a0 20 74 79 70 65 c2 a0 44 65 73 |Unit.. type..Des|
00000040 63 72 69 70 74 69 6f 6e c2 a0 0d 0a |cription....|
No replacements happend
Attempt 2: Using vim
vim file1.txt
:set nobomb
:set fileencoding=utf-8
:wq
Used sed again and no replacements happened. How do I replace or remove those characters (hex "c2a0")?
I finally ended up using Perl which successfully removed the unicode chars.
> perl -v
This is perl 5, version 18, subversion 2 (v5.18.2) built for darwin-thread-multi-2level
> perl -pi -e 's/\x{c2}\x{a0}//g' file1.txt
> head -n1 file1.txt | hexdump -C
00000000 47 72 6f 75 70 20 20 20 53 69 67 6e 61 6c 6e 61 |Group Signalna|
00000010 6d 65 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |me |
00000020 20 20 20 20 20 20 20 20 20 20 55 6e 69 74 20 74 | Unit t|
00000030 79 70 65 44 65 73 63 72 69 70 74 69 6f 6e 0d 0a |ypeDescription..|
00000040
Here is my CoffeeScript:
buffer = new Buffer 100
buffer[i] = i for i in [0..99]
console.log buffer
which compiles to
var buffer, i;
buffer = new Buffer(100);
for (i = 0; i < buffer.length; i++) {
buffer[i] = i;
}
console.log(buffer);
When I run it with node, I get the following output:
$ coffee exercise1
<Buffer 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63>
instead of 0 to 99. Why is that?
Ray nailed it in his comment. See the Buffer documentation; you have to specify an encoding argument (you probably want 'utf8') on a Buffer's toString.
// coffeescript
console.log buffer.toString 'utf8'
// javascript
console.log(buffer.toString('utf8'));