hexdump in Objective-C - ios

I want to see the dump of my sqlite .db file inside my Xcode project like on a UILableView.
How can I run a command line command like hexdump from within my iOS app?

How can I run a command line command like hexdump from within my iOS app?
On MacOS X, you could do this using NSTask to run whatever program you want. You'd use NSPipe to send data to and/or get data from the command.
But you can't do that on iOS. First of all, the hexdump command may or may not exist in a standard iOS installation. Second, NSTask isn't available. If you really just want to dump the bytes from a file into a label, it's not difficult. I'd look at using NSInputStream to open the file and read its data, and then convert each byte to an appropriate hex string and add that to a larger string that'll accumulate the total dump. Once you're done, assign that larger string as the text of the label. Or, you could do the same thing yourself by just reading the file into an instance of NSData and iterate over the bytes yourself to produce the hex string.

Use NSData to read the file as raw data, then display the bytes however you want (for example, using a format string).
-actually from another user #jtbandes

Related

How to print out ASCII to a separate file.

I am trying to print data using
*EL PRINT
to a separate file other that jobname.dat file.
Is there any way to do this?
PS: I know how to export the data from the odb file.
Thanks
As far as I know you can't reroute that kind of input-file keyword output request to a different file. I've listed some alternatives below:
As you mention, you can script it using the Abaqus/Python API.
You can manually print results to a file of your choosing from the Viewer.
You can access the results file for postprocessing using a Fortran or C++ program (search for ABQMAIN).
You can access results and write them to a file of your choosing during the analysis using the Fortran subroutine URDFIL.

how to overwrite, or delete the file, used by writefile() calls?

I use the following to save screen output to a file
writefile("file.txt"),
tex(expression),
closefile()
The above sends the output of the tex() to the file automatically. which is all and well and what I want. (side-point: It also sends an annoying NIL line each time to the file, which I had to parse put later).
Now, when running the above code again, the file is appended to, which is not what I want. I want to either overwrite the file each time, or if there is a way to delete the file, so I can call delete on it before.
I looked at help and not able to find a command to delete a file, and I also see no option to tell writefile() to overwrite the file?
Is there an option or way around this? I am on windows 7, Maxima version: 5.36.1
Lisp: SBCL 1.2.7
I guess you are trying to capture the output of tex into a file. If so, here are a couple of other ways to do it:
tex (expr, destination);
where destination is either a file name (which is appended) or a stream, as created by opena or openw and closed by close. By the way, destination could be false, in which case tex returns a string.
with_stdout (destination, tex (expr));
where again destination is either a file name (which is appended or clobbered, as determined by the global flag file_output_append) or a stream.
with_stdout could be useful if you want to mix in some output not generated by tex, e.g., print("% some commentary");.

How to separate the "comma separated values string" whose values in turn contain commas [duplicate]

I have to develop an iOS application that can read the data from a CSV file hosted on a domain. Is there any standard APIs that can help me to do this? I don't need to download but just read the file because the file will be updated for every two mins.
I recommend Dave DeLong's CHCSVParser library for parsing.
You will have to download the file, that is the only way to get it from the remote host to your device. A CSV File is a text file with data separated by a comma(','). Download the file from the the remote host, read the file line by line, split the line string that was read from the file;
For example:
1,2,3,4,1,2,3 ...Line 1
Split using ',' as a delimiter and add the split values into an array, the result will be:
array_line_one = {1,2,3,4,1,2,3};

How can I change a huge text file from ANSI to UTF-8?

I have a text file whose size is 1.3 GB. Most of text editors (including NotePad++) cannot open it. I need to change its format from ANSI to UTF-8. In what program can I do this?
Try EmEditor. It supports Huge files very well. Free version exists.
If you want a free (and open source) command-line tool that can run on Windows, and which allows you to convert huge files from ANSI to UTF-8 (or any other encodings), you can use this tool that I've just created (runs on nodejs and uses the iconv-lite library):
https://github.com/sorin-postelnicu/convert-file-encoding
You can use it like this:
node bin\convertFileEncoding.js -f latin-1 -t utf-8 -i myinputfile.txt -o myoutputfile.txt
It is fast and supports converting very large files with minimal memory consumption (around 20MB of RAM no matter the size of the input file).
You can also use shareware text editor UltraEdit.
First, configure UltraEdit for editing large files according to power tip large file text editor.
Then open your file in UltraEdit and use File - Save As and select for Encoding (Windows 7/8/8.1/Vista) respectively Format (Windows XP/2000) the option UTF-8 - NO BOM or UTF-8 for saving with conversion to UTF-8 encoding without or with byte order mark at beginning of the file.

Reading and Parsing a .MID file with Lua?

I am trying to read a .MID file with Lua and then parsing it into a table with all of the notes (ie {"A", "B#", "Cb", etc.}) but I cannot manage to read the file correctly. I use io.open and file:lines() but writing those same lines into another midi file results in a non-working midi file.
Is there any easier way to read and parse a .MID file with Lua?
The Standard MIDI File format is binary, not text. So you cannot expect to read it as "lines" at all. Instead, you'll need to use the read function to get bytes and inspect them. You might be better off finding a C library for MIDI files and binding it to Lua.
.MID files (presumably Standard MIDI format) are binary, not text. Reading them with file:lines() will not work. You need to read the entire thing into a "string" (Lua strings can hold arbitrary bytes of data) with file:read("*a") instead; this will read the entire file into a single string. You also need to make sure that you open the file in binary mode (for platforms where this makes a difference).
There seems to be a framework called MIDI.lua for parsing MIDI data. Not sure how well it handles MIDI files, though.

Resources