Write a C program, called utf_convert, that will read a file in either UTF-32 or UTF-16, and output the same file in the other format. Characters should be written to the file in Little Endian format.
./utf_convert input32 output16 32denotes reading the contents of the file input32, which is formatted in UTF-32, and write it to output16 in UTF-16.
./utf_convert input16 output32 16denotes reading the contents of the file input16, which is formatted in UTF-16, and write it to output32 in UTF-32.
./utf_convert input outputdenotes reading the content of input and figuring out if is more likely that input is in UTF-16 format, or UTF-32 format, and writing a translated version to output, translating to whatever input is not.
Note that you should validate the command line arguments. This means making sure that there are the correct number of arguments, and making sure that the arguments are all valid. For example, attempting to read from a file that does not exist should not crash your program, but should instead prompt a graceful exit with a helpful error message. Likewise, specifying an invalid format should also produce a graceful exit with a helpful error message.
An empty input file is okay. You should simply produce an empty output file.
If an error is detected, print an appropriate error message to stderr that includes the offset in the file for the start byte for the sequence that is in error. In the case of an unexpected continuation byte, print the offset of that byte.
You may exit the program after reporting the first error.
The program will return a status of -1 if it is detected that the file is not valid; othewise it will return a status of 0.
Put all your source code in the file utf_convert.c. It will be automatically compiled when grading assuming that your source file is named utf_convert.c.
In addition, remember, you may lose points if your program is not properly structured or adequately documented. Coding guidelines are given on the course overview webpage.
Your programs will be graded using agate.cs.unh.edu so be sure to test in that environment.
Remember: as always you are expected to do your own work on this assignment. Copying code from another student or from sites on the internet is explicitly forbidden!
% ~cs520/bin/DoSubmission.py prog1 utf_convert.c
This submission script is new. It passed what testing I have done on it, but it may still have issues. If there are any problems, please contact me via email and I will do my best to assist you. If I cannot be reached, please send me a copy of your assignment via email, and we will deal with the submission script later.