diff options
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/doc_document.c | 2 | ||||
-rw-r--r-- | fitz/fitz.h | 17 | ||||
-rw-r--r-- | fitz/stm_open.c | 14 |
3 files changed, 26 insertions, 7 deletions
diff --git a/fitz/doc_document.c b/fitz/doc_document.c index 15ad4b62..22229892 100644 --- a/fitz/doc_document.c +++ b/fitz/doc_document.c @@ -27,7 +27,7 @@ fz_document * fz_open_document(fz_context *ctx, char *filename) { char *ext = strrchr(filename, '.'); - if (ext && !fz_strcasecmp(ext, ".xps")) + if (ext && (!fz_strcasecmp(ext, ".xps") || !fz_strcasecmp(ext, ".rels"))) return (fz_document*) xps_open_document(ctx, filename); if (ext && !fz_strcasecmp(ext, ".cbz")) return (fz_document*) cbz_open_document(ctx, filename); diff --git a/fitz/fitz.h b/fitz/fitz.h index 48b67ff8..9e0c0311 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -534,20 +534,20 @@ int fz_strlcpy(char *dst, const char *src, int n); int fz_strlcat(char *dst, const char *src, int n); /* - fz_chartorune: UTF8 decode a string of chars to a rune. + fz_chartorune: UTF8 decode a single rune from a sequence of chars. rune: Pointer to an int to assign the decoded 'rune' to. - str: Pointer to a UTF8 encoded string + str: Pointer to a UTF8 encoded string. Returns the number of bytes consumed. Does not throw exceptions. */ int fz_chartorune(int *rune, char *str); /* - runetochar: UTF8 encode a run to a string of chars. + fz_runetochar: UTF8 encode a rune to a sequence of chars. - str: Pointer to a place to put the UTF8 encoded string. + str: Pointer to a place to put the UTF8 encoded character. rune: Pointer to a 'rune'. @@ -557,7 +557,7 @@ int fz_chartorune(int *rune, char *str); int fz_runetochar(char *str, int rune); /* - fz_runelen: Count many chars are required to represent a rune. + fz_runelen: Count how many chars are required to represent a rune. rune: The rune to encode. @@ -986,7 +986,12 @@ typedef struct fz_stream_s fz_stream; /* fz_open_file: Open the named file and wrap it in a stream. - filename: Path to a file as it would be given to open(2). + filename: Path to a file. On non-Windows machines the filename should + be exactly as it would be passed to open(2). On Windows machines, the + path should be UTF-8 encoded so that non-ASCII characters can be + represented. Other platforms do the encoding as standard anyway (and + in most cases, particularly for MacOS and Linux, the encoding they + use is UTF-8 anyway). */ fz_stream *fz_open_file(fz_context *ctx, const char *filename); diff --git a/fitz/stm_open.c b/fitz/stm_open.c index 1e303825..ced32d80 100644 --- a/fitz/stm_open.c +++ b/fitz/stm_open.c @@ -129,7 +129,21 @@ fz_open_fd(fz_context *ctx, int fd) fz_stream * fz_open_file(fz_context *ctx, const char *name) { +#ifdef _WIN32 + char *s = (char*)name; + wchar_t *wname, *d; + int c, fd; + d = wname = fz_malloc(ctx, (strlen(name)+1) * sizeof(wchar_t)); + while (*s) { + s += fz_chartorune(&c, s); + *d++ = c; + } + *d = 0; + fd = _wopen(wname, O_BINARY | O_RDONLY, 0); + fz_free(ctx, wname); +#else int fd = open(name, O_BINARY | O_RDONLY, 0); +#endif if (fd == -1) fz_throw(ctx, "cannot open %s", name); return fz_open_fd(ctx, fd); |