Skip navigation.
 
mlRe: writing huge C-array to a file
FROM : Tommy Nordgren
DATE : Fri Jul 21 17:44:56 2006

21 jul 2006 kl. 17.04 skrev PGM:

> Hey everybody
>
> In my app, I have a document containing a potentially huge two-
> dimensional C-array filled with doubles that I need to write to a 
> file (with a user-specified number of decimals). My original plan 
> was to use NSDocument's "dataRepresentationOfType" and fill an 
> NSMutableString with the text and use that. However, this takes 
> forever because the NSMutableString has to allocate additional 
> memory again and again ("initWithCapacity" did not help much).
>
> What I did then is to use "writeToFile:ofType:" and then use plain 
> C to write the data to a file:
>
>         FILE *writing;
>      double **matrix = [myData distanceMatrix];
>      const char *out_name;
>      out_name = [fileName cString];
>      writing = fopen(out_name, "w");
>     fprintf(writing, everything); //looping over the matrix
>
> This works, but I am afraid that it will break when the fileName 
> contains non-ASCII characters. Is there another fast way to write a 
> large C-array to a file that does work with non-ASCII filenames?
>
> Thanks in advance, Patrick
>

   Test with [filename UTF8String]
I have tested this with a small project, using Swedish characters

-------------------------------------
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
tommy.<email_removed>

Related mailsAuthorDate
mlwriting huge C-array to a file PGM Jul 21, 17:04
mlRe: writing huge C-array to a file Dado Colussi Jul 21, 17:27
mlRe: writing huge C-array to a file Tommy Nordgren Jul 21, 17:44
mlConverting file names to C strings (was Re: writing huge C-array to a file) Douglas Davidson Jul 21, 17:54
mlRe: writing huge C-array to a file Bill Bumgarner Jul 21, 18:01
mlRe: writing huge C-array to a file Uli Kusterer Jul 21, 18:21
mlRe: writing huge C-array to a file Steve Bird Jul 24, 03:29
mlRe: writing huge C-array to a file Bill Bumgarner Jul 24, 04:26
mlRe: writing huge C-array to a file PGM Jul 24, 04:40
mlRe: writing huge C-array to a file Jakob Olesen Jul 24, 10:15
mlRe: writing huge C-array to a file PGM Jul 24, 15:55
mlRe: Re: writing huge C-array to a file Michael Ash Jul 24, 17:39