Strange character for empty line in TextWrangler and cat -v - ascii

I have a text file, which on my Mac I open with TextWrangler. I enable the invisible characters to see the line endings. I see that every empty line has a red, upside down question mark in it. Which character is this?
When in the terminal I type cat -v file.txt, it shows these characters as ^# (and the line endings themselves as ^M). What I need to know is the regex of that specific character, like /n for the end of line.
In the hex dump, I see the following:
0000000: 312e 300d 0a00 0d0a 2231 3130 3030 3030 1.0....."1100000
0000010: 3030 3222 3b22 3922 3b22 5354 4422 3b3b 002";"9";"STD";;
0000020: 3b0d 0a22 3131 3030 3030 3030 3639 223b ;.."1100000069";
If I manually remove the strange characters, and make a new hex dump, I see:
0000000: 312e 300d 0a0d 0a22 3131 3030 3030 3030 1.0...."11000000
0000010: 3032 223b 2239 223b 2253 5444 223b 3b3b 02";"9";"STD";;;
0000020: 0d0a 2231 3130 3030 3030 3036 3922 3b22 .."1100000069";"
The difference is a byte sequence 00. Is there an encoding in which this 00 is required for empty lines?

The red inverted question mark, you are looking at, is apparently a NULL / NUL character. Whether or not it makes any difference does depend on the application writing/reading the files in question. (So, it's most likely not a general encoding issue of sorts. Compare: Wikipedia.)
Once you made the hidden characters visible in TextWrangler, you can mark that/any character (or character sequence for that matter), and copy it to the Find input field using CMD + E. The NULL character shows up as \x{00} on my machine.
Alternatively, you might use -> Text -> Zap Gremlins... with (at least) Null (ASCII 0) characters checked, Replace with code selected, and were told \x00. Either one of these should work when searching for these characters - no matter whether grep is enabled or not. Not sure, though, whether \s should actually find it as well in grep mode - it does not on my machine. But \W does grep it.
Please comment, if and as this requires adjustment / further detail.

Related

in ruby in windows, executing the cmd prompt command 'move' gives error "The syntax of the command is incorrect."

in ruby in windows, executing the cmd prompt command 'move' gives error "The syntax of the command is incorrect."
But it works outside of ruby
C:\rubytest>echo asdf>c:\techprogs\azzz.azz
C:\rubytest>del c:\techprogs\azzz.azz
C:\rubytest>echo asdf>c:\techprogs\azzz.azz
C:\rubytest>move /y c:\techprogs\azzz.azz c:\techprogs\autorun.bat
1 file(s) moved.
C:\rubytest>move /y c:\techprogs\azzz.azz c:\techprogs\autorun.bat
The system cannot find the file specified.
C:\rubytest>
All of that above is fine and expected.
Notice I never get an error that says "The syntax of the command is incorrect."
Then try in ruby
I have a simple file with one line
C:\rubytest>type syntaxcommandincorrect.rb
`move /y c:\techprogs\azzz.azz c:\techprogs\autorun.bat`
C:\rubytest>
But it gives that error about the syntax
C:\rubytest>del c:\techprogs\azzz.azz
C:\rubytest>ruby syntaxcommandincorrect.rb
The syntax of the command is incorrect.
C:\rubytest>echo asdf>c:\techprogs\azzz.azz
C:\rubytest>ruby syntaxcommandincorrect.rb
The syntax of the command is incorrect.
C:\rubytest>
The problem here is probably the backslashes which have significant meaning inside of interpolated Ruby strings, double-quoted but also backtick-style shell commands.
As such your command is being interpreted as:
move /y c:^Iechprogs^Gzzz.azz c:^Iechprogs^Gutorun.bat
Where ^I is "\t" which is a tab character, and ^G is "\a" which is a bell character.
Instead:
`move /y c:\\techprogs\\azzz.azz c:\\techprogs\\autorun.bat`
Now remember that Ruby has a very comprehensive library of functions you can use to address this directly. Don't treat it like a fancy shell scripting language:
require 'fileutils'
FileUtils.mv('c:\techprogs\azzz.azz', 'c:\techprogs\autorun.bat', force: true)
Where here I'm using single quotes to avoid the double backslashes and force: true is the equivalent of /y. This uses FileUtils.mv, part of a whole package of useful file and directory manipulation utilities.
As a plus you also get proper exceptions if something goes wrong, or an error code if the move failed.
Added by barlop
Confirming the above. Double backslash fixes it, and i see via doing puts `echo copy /y c:\techprogs...` what happens with single backslash, I see the t of techprogs removed, as c:\techprogs became c:<ascii-9>echprogs. And \autorun became <ascii-7>utorun
C:\rubytest>cmdoutoutwithoutinitbat.rb | xxd
0000000: 6162 6364 6566 670d 0a63 6f70 7920 2f79 abcdefg..copy /y
0000010: 2063 3a09 6563 6870 726f 6773 0775 746f c:.echprogs.uto
0000020: 7275 6e2e 6261 7420 633a 0965 6368 7072 run.bat c:.echpr
0000030: 6f67 7307 7a7a 7a2e 617a 7a0d 0a61 6263 ogs.zzz.azz..abc
0000040: 6465 6667 0d0a 6d6f 7665 202f 7920 633a defg..move /y c:
0000050: 0965 6368 7072 6f67 7307 7a7a 7a2e 617a .echprogs.zzz.az
0000060: 7a20 633a 0965 6368 7072 6f67 7307 7574 z c:.echprogs.ut
0000070: 6f72 756e 2e62 6174 0d0a orun.bat..
C:\rubytest>

SoftQuad DESC or font file binary

I read this question but it doesn't helped me. I am solving a challenge where I have two files, first one was .png which gave me upper half part of an image, second file is SoftQuad DESC or font file binary I am sure that this file should somehow convert into .png file to complete the image. I googled and got hint about magic bytes but I am unable to match the bytes.
These are the first two rows of output of xxd command
00000000: aaaa a6bb 67bb bf18 dd94 15e6 252c 0a2f ....g.......%,./
00000010: fe14 d943 e8b5 6ad5 2264 1632 646e debc ...C..j."d.2dn..
These are the last two rows of output of xxd command
00001c10: 7a05 7f4c 3600 0000 0049 454e 44ae 4260 z..L6....IEND.B`
00001c20: 82
.

netsh add sslcert parameter is incorrect from cmd

Note that, while there is a lot on this issue already, it invariably covers either using this from powershell (where braces and dashes can be an issue) or a typo in the docs where ipport is followed by a colon.
I am in cmd
C:> netsh http add sslcert ipport=0.0.0.0:8180 appid={12345678-db90-4b66-8b01-88f7af2e36bf} certhash=‎1234567890
The parameter is incorrect.
In actual usagge I'm using the correct certhash I got from my certificate store - not the obviously fake one above
So what is going on? Is there a way to get more info?
Explained in my comment:
I'm using the correct certhash… Supposedly "The SHA hash of the certificate. This hash is 20 bytes long and specified as a hex
string" instead of fake 1234567890?
However, there is a harmful format symbol Left-To-Right Mark (Unicode
U+200E) after Equals Sign in your certhash=‎1234567890
Screenshot taken from Unicode Analyzer:
Another way to detect invisible characters using my Alt KeyCode Finder script:
==> mycharmap h=‎1
Ch Unicode Alt? CP IME Alt Alt0 IME 0405/cs-CZ; CP852; ANSI 1250
h U+0068 104 …104… 104 0104 Latin Small Letter H
= U+003D 61 …61… 61 061 Equals Sign
‎ U+200E 8206 …14… Left-To-Right Mark
CP862 he-IL 0253 (ANSI 1255) Hebrew
CP720 ar-EG 0253 (ANSI 1256) Arabic
1 U+0031 49 …49… 49 049 Digit One
h=‎1
==> chcp
Active code page: 852

character set changing or what?

I am a bit confused about this topic. Same sentences's google result could be different?
peоple in thе wоrld
At first you can search the firts sentence at google and look at the result. And after
people in the world
Seacrh second sentence and notice the differents.
How could it be?
If you dump it as hex, you can see the difference. I just ran it through xxd.
The first sentence:
0000000: 7065 d0be 706c 6520 696e 2074 68d0 b520 pe..ple in th..
0000010: 77d0 be72 6c64 0a w..rld.
The second sentence:
0000000: 7065 6f70 6c65 2069 6e20 7468 6520 776f people in the wo
0000010: 726c 640a rld.
This one appears to be valid ASCII.
Both look very similar, but instead the first sentence uses the unicode character set and uses Cyrillic characters instead of normal ASCII ones.

Images corrupt after git push

I added some .png images to my git repo and then pushed them to my remote repository. I noticed that the images are in the remote repository, but they are broken.
In order to verify this, I compared the binary data for the images on my local and my remote repos. I also ran the file command on images in both repos.
Image on local repository
First 10 Lines of Binary data:
8950 4e47 0d0a 1a0a 0000 000d 4948 4452
0000 0019 0000 0014 0806 0000 0078 7796
bd00 0000 1974 4558 7453 6f66 7477 6172
6500 4164 6f62 6520 496d 6167 6552 6561
6479 71c9 653c 0000 0373 6954 5874 584d
4c3a 636f 6d2e 6164 6f62 652e 786d 7000
0000 0000 3c3f 7870 6163 6b65 7420 6265
6769 6e3d 22ef bbbf 2220 6964 3d22 5735
4d30 4d70 4365 6869 487a 7265 537a 4e54
637a 6b63 3964 223f 3e20 3c78 3a78 6d70
Result of file command:
bundles/admin/public/images/messages-icon.png: PNG image data, 24 x 16, 8-bit/color RGBA, non-interlaced
Image pushed to remote repository
First 10 Lines of Binary data:
8950 4e47 0a1a 0a00 0000 0d49 4844 5200
0000 1900 0000 1408 0600 0000 7877 96bd
0000 0019 7445 5874 536f 6674 7761 7265
0041 646f 6265 2049 6d61 6765 5265 6164
7971 c965 3c00 0003 7369 5458 7458 4d4c
3a63 6f6d 2e61 646f 6265 2e78 6d70 0000
0000 003c 3f78 7061 636b 6574 2062 6567
696e 3d22 efbb bf22 2069 643d 2257 354d
304d 7043 6568 6948 7a72 6553 7a4e 5463
7a6b 6339 6422 3f3e 203c 783a 786d 706d
Result of file command:
bundles/admin/public/images/notifications-icon.png: data
Why would this be happening? I searched all over google and this site for answers but have found none.
I had this issue too - here's a generic .gitattributes that looks generally safe for php web repos that worked for me: https://github.com/Danimoth/gitattributes/blob/master/Web.gitattributes
running git check-attr --all -- path/to/png before and after adding the new gitattributes showed that the image file was originally treated as a text file, and now it's binary (note I had to commit/push the .gitattributes file for it to take effect on remote)
In case the link goes dead:
# These settings are for any web project
# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
# * text=auto
# NOTE - originally I had the above line un-commented. it caused me a lot of grief related to line endings because I was dealing with WordPress plugins and the website changing line endings out if a user modified a plugin through the web interface. commenting this line out seems to have alleviated the git chaos where simply switching to a branch caused it to believe 500 files were modified.
#
# The above will handle all files NOT found below
#
#
## These files are text and should be normalized (Convert crlf => lf)
#
# source code
*.php text
*.css text
*.sass text
*.scss text
*.less text
*.styl text
*.js text
*.coffee text
*.json text
*.htm text
*.html text
*.xml text
*.svg text
*.txt text
*.ini text
*.inc text
*.pl text
*.rb text
*.py text
*.scm text
*.sql text
*.sh text
*.bat text
# templates
*.ejs text
*.hbt text
*.jade text
*.haml text
*.hbs text
*.dot text
*.tmpl text
*.phtml text
# server config
.htaccess text
# git config
.gitattributes text
.gitignore text
.gitconfig text
# code analysis config
.jshintrc text
.jscsrc text
.jshintignore text
.csslintrc text
# misc config
*.yaml text
*.yml text
.editorconfig text
# build config
*.npmignore text
*.bowerrc text
# Heroku
Procfile text
.slugignore text
# Documentation
*.md text
LICENSE text
AUTHORS text
#
## These files are binary and should be left untouched
#
# (binary is a macro for -text -diff)
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.mov binary
*.mp4 binary
*.mp3 binary
*.flv binary
*.fla binary
*.swf binary
*.gz binary
*.zip binary
*.7z binary
*.ttf binary
*.eot binary
*.woff binary
*.pyc binary
*.pdf binary
*.png binary
in .gitattribute worked after images were reuploaded.
You can add all images by executing git add *.png --force

Resources