bugSimple C Expat Wrapper - Bugs: bug #24374, [Feature request] Add wchar_t...

 
 

bug #24374: [Feature request] Add wchar_t interface to open an XML-file

Submitted by:  None
Submitted on:  Thu 25 Sep 2008 07:18:19 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Wont Fix
Privacy: PublicAssigned to: Aleix Conchillo Flaqué <aleix>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Mon 24 Aug 2009 10:42:41 PM UTC, comment #6:

In order to keep the library standard for most OSs I will not add this functionality, as one can easily use scew_parser_load_file passing the file pointer returned by wopen.

Aleix Conchillo Flaqué <aleix>
Project AdministratorIn charge of this item.
Thu 02 Oct 2008 06:51:06 PM UTC, comment #5:

OK, I see... wfopen is not standard, so I will check how other libraries handle this.

I'll keep you informed.

Aleix Conchillo Flaqué <aleix>
Project AdministratorIn charge of this item.
Thu 02 Oct 2008 06:07:47 PM UTC, comment #4:

scew_bool
scew_parser_load_file_w (scew_parser parser, wchar_t* const file_name)

...is correct (forgot * operator)

Anonymous
Thu 02 Oct 2008 06:06:37 PM UTC, comment #3:

Under Windows localized path names are stored as UTF-16 strings. The fopen function needs an input string as ANSI string. If I convert an UTF-16 (wchar_t) string to ANSI, I will loose information (tested on Japanese Windows XP).

For this issue the file need to be opened with wfopen.

A possible solution could be:

scew_bool
scew_parser_load_file_w (scew_parser parser, wchar_t const file_name)
{
FILE *in = NULL;
scew_bool result = SCEW_FALSE;

assert (parser != NULL);
assert (file_name != NULL);

in = wfopen (file_name, L"rb");
if (in == NULL)
{
scew_error_set_last_error_ (scew_error_io);
return result;
}

result = scew_parser_load_file_fp (parser, in);
fclose (in);

return result;
}

Chris

Anonymous
Thu 02 Oct 2008 05:25:16 PM UTC, comment #2:

I have investigated this issue a bit and fopen should be able to open files with unicode names.

I have tried it under Linux and Mac OS X and works well.

#include <stdio.h>
#include <stdlib.h>

int
main (int argc, char *argv[])
{
FILE *f = fopen ("és una prova.txt", "r");

printf ("%s\n", (f == NULL) ? "error" : "success");

return EXIT_SUCCESS;
}

Aleix Conchillo Flaqué <aleix>
Project AdministratorIn charge of this item.
Mon 29 Sep 2008 07:36:20 AM UTC, comment #1:

May be I could use XML_Char which uses wchar_t if XML_UNICODE_WCHAR_T is defined, but this will force to add the define and it could not be necessary in some cases.

Another function would probably be better as you suggest. I'll think about it.

Thanks!

Aleix Conchillo Flaqué <aleix>
Project AdministratorIn charge of this item.
Thu 25 Sep 2008 07:18:19 AM UTC, original submission:

Hi,

It would be nice if the scewxml parser has an additional interface scew_parser_load_file which needs a const wchar_t* file_name as input parameter.
The function to load a file by an ANSI path does not work if you have unicode paths.
To avoid this I use the function scew_parser_load_file_fp. This as the disadvantage (on win32) that you always need a version of the scewxml library that was exactly compiled with the same runtime library (e.g. debug/release).
For this issue it would be more comfortable to have a new interface from which you can load an XML file directly by an wchar_t* path

Chris

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by aleix (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 24 Aug 2009 10:42:41 PM UTCaleixStatusConfirmed=>Wont Fix
      Open/ClosedOpen=>Closed
    Thu 02 Oct 2008 06:51:06 PM UTCaleixStatusInvalid=>Confirmed
    Thu 02 Oct 2008 05:25:15 PM UTCaleixStatusIn Progress=>Invalid
    Mon 29 Sep 2008 07:36:20 AM UTCaleixStatusNone=>In Progress
      Assigned toNone=>aleix

    Back to the top


    Powered by Savane 3.1-cleanup1