convert file type from "UTF-8 Unicode text" to "C source, ISO-8859 text" - linux

I am a programmer. I write C code in Linux using GCC, and they can run correctly. Now, I want to run these codes in Windows system using Visual studio 2015. But it always show some errors and warnings as following:
1>f:\md\test_sm3_hmac_02\tools.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
1>f:\md\test_sm3_hmac_02\types.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
1>f:\md\test_sm3_hmac_02\tools.h(13): error C2143: syntax error: missing ')' before '*'
1>f:\md\test_sm3_hmac_02\tools.h(13): error C2143: syntax error: missing '{' before '*'
when I open every file and copy they in new file that is created in windows and don't do any others change. It runs correctly. But my project contains many file and I don't do this to solve this problem.
I want to solve it by doing few work.
The format of file created by VS2015 in windows is:
$ file testtypes.h
testtypes.h: C source, ISO-8859 text
The format of file created by touch in linux is:
$ file filetest.c
filetest.c: UTF-8 Unicode text
How can i do ?

Related

How to enter windows paths to run Python in Sublime Text 3 using Ctrl+B

I'm trying to run a python script using Sublime Text 3. I'm trying to just use Ctrl+b and type the parameters in the box that comes up, but I can't for the life of me figure out how to format the Windows file paths. I keep getting a FileNotFoundError
I've tried:
"C:\dir1\dir 2\file.ext"
"C:\\dir1\\dir 2\\file.ext"
"C:/dir1/dir 2/file.ext"
Because some of my directories have spaces in them, I'm enclosing the whole thing in double quotes no matter which slash style I try. What am I missing here? None of these works.
With the first, for example, I'm getting FileNotFoundError: [Errno 2] No such file or directory: 'C:\\dir1\\dir 2\\file.ext,' [Finished in 0.3s]
The file is most definitely there and spelled correctly.
In case it matters, I'm using docopt to parse the input parameters

Compile python file that references to xlsx files without compiling the xslx files

I am trying to compile my py file but end up with an error.
The scripts reads from 2 excel files and write back to 1
When compiling the py file i get error FileNotFoundError: [Errno 2] No such file or directory: 'file.xlsx'. While the file is there and can be found when i execute the py file I cant seems to fix this.
When i chande the path from relative to full, this error pops up
workbook = load_workbook(filename="C:\Users\userxdx\Desktop\Excellsupport\file.xlsx")
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
To compile I make use of py2exe (for windows)
what am i missing here?
This is not working because a \ is an escape character. For example, "\n" will create a new line in a string. To ignore escape characters, place an r at the beginning of the string like so:
filename=r"C:\Users\userxdx\Desktop\Excellsupport\file.xlsx"

yaml syntax error for ansible base64 multi line variable

Ansible Version: 2.1.2.0
So I have a yaml file with a multi line variable that's from a binary file converted to base 64.
My variable file: self-cert.yml
selfcert: |
MIIKCAIBAzCCCcIGCSqGSIb3DQEHAaCCCbMEggmvMIIJqzCCBWgGCSqGSIb3DQEHAaCCBVkEggVV
MIIFUTCCBU0GCyqGSIb3DQEMCgECoIIE+jCCBPYwKAYKKoZIhvcNAQwBAzAaBBQFa98IY7UgblDK
qGwMjTIQCK+3DwICBAAEggTIvA/VFm3j3oSN6cknp5qFyUxXAI5TxURnyx8UVRm8UfMcA0LHlh+z
06ztcwApIrxMSV26ezu0p1FrHInpbABNuO0rlk4XlQwTkLynUyg58iBwK7IyV5SqT2UC8djaOiMN
b9ViC3yn7SrRdS3MmCQznu6dScRIHbhG46yZNJrzrJh038X2KAPpS/LfC9DJBjaEzkZY8BwyARYe
When I try to run my playbook that includes this variable, I get:
ERROR! Syntax Error while loading YAML.
The error appears to have been in '/home/ansible/projects/install-cert/self-cert.yml': line 3, column 1, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
MIIKCAIBAzCCCcIGCSqGSIb3DQEHAaCCCbMEggmvMIIJqzCCBWgGCSqGSIb3DQEHAaCCBVkEggVV
MIIFUTCCBU0GCyqGSIb3DQEMCgECoIIE+jCCBPYwKAYKKoZIhvcNAQwBAzAaBBQFa98IY7UgblDK
^ here
Any idea whats wrong? I've tried changing | to > , didn't work, and i've also tried indenting the whole base64 output too.
So it turns out you do need to make an indentation to the the multiline variable. My original indentation was an actual tab instead of spaces (Stupid Sublime) and so the indentation failed the syntax check, but using actual spaces made everything work.

Preserving accentuated letters when running a PERL script from linux terminal

I want to get a plain text file from the French Wikipedia dump XML file.
To that end, I am applying a Perl script
I can give the full file if necessary, I only added the line
tr/a-zàâééèëêîôûùç-/ /cs;
to the script here: http://mattmahoney.net/dc/textdata.html
However, when I run on linux terminal:
perl filterwikifr.pl frwiki.xml > frwikiplaintext.txt
the output text file does not print accentuated letters correctly. For example, I get catégorie instead of catégorie...
I also tried:
perl -CS filterwikifr.pl frwiki.xml > frwikiplaintext.txt
without better success (and other variants instead of -CS...)
the problem is with the text editor gedit.
If, instead of opening the file directly, I open gedit, and then go to "open" and down, in "Character encoding", I choose UTF-8 instead of "Automatically Detected", then the accents are printed correctly.

Windres syntax error

I am working in MinGW environment (downloaded with their installer on 12/12/2011). I am attempting to compile a resource (.rc) file using Windres. The specific command I use is
Windres -O coff About1.rc -o About1.res
Windres generates at least 100 lines of warning messages reading: "warning: null characters ignored". Following this Windres emits: "Abouty1.rc:1:syntax error".
As a matter of fact, there are no null characters in the About1.rc file. In addtition, the first line of the file is an include statement: #include "dlgresource.h". I played around and eliminated this statement and it turns out that it doesn't matter what I put there, I get the same flurry of messages and the syntax error notification.
To make things more confusing, this same .rc file compiles without any problem using MSFT's rc.exe. The resulting .res file links smoothly with the program .obj file and runs perfectly.
I have no idea what is going on. Any ideas?
Thanks,
Mark Allyn
Your .rc file is probably encoded as UTF-16.
That's what's required in general by Microsoft's [rc.exe], in order to be able to deal with international characters, but GNU [windres.exe] can only deal with ANSI encoding.
One workaround is to convert the file to ANSI on the spot (possibly losing e.g. Russian or Greek characters):
> chcp 1252
Active code page: 1252
> type my.rc | windres --output-format=COFF -o my.res
> _
You probably used VS or a similar tool to generate the file. There are some parts of the character encodings that you cannot see resulting in null characters and etc.
Generate a new .res file with the same content, don't copy/paste the content, type it in yourself.
Try:
windres About1.rc -o About1.o
and then just use the resulting .o file instead of the originally intended .res file.
I've had the same troubles than you today. I know it has passed a lot of time from your question, but I'm writting this on the hope that it can be useful for someone.
First, I obtained an object file .o compiled using Cygwin, writting:
windres -o resource.o resource.rc
By doing that, you dont need to use the .res file, but the .o one, and you can then link this object with all the others, when you compile yout program, using GNU resources:
g++ Header_files CPP_files flags ... -o program.exe recource.o -lm
For instance.

Resources