wstring, encoding or whatever is this Sh#t all about?!

Products and tips

Moderator: Site Mods

Post Reply
sanferno
Silver Member
Silver Member
Posts: 271
Joined: 2013 Nov 30, 18:40

wstring, encoding or whatever is this Sh#t all about?!

Post by sanferno » 2016 Sep 13, 15:54

Hi, I've been struggling with the next situation all day, I hope someone could help me.

Dealing with an API that requires the use of "wstring" (that seems to be encoded internally as UTF16) for creating a folder named with this patron "name.gdb", the real result is "歐Âname.gdb" (first two characters look like they are in Chinese). For English systems seems to be working fine, but not for Spanish... so, could you give any clue? :evil:

PS: I could provide more info if needed

Kilmatead
Platinum Member
Platinum Member
Posts: 4569
Joined: 2008 Sep 30, 06:52
Location: Dublin

Re: wstring, encoding or whatever is this Sh#t all about?!

Post by Kilmatead » 2016 Sep 13, 19:35

'wstring' is just a character class that is for unicode ("wide-string" wchar_t) style characters. MS uses UTF-16 (2-bytes per character) as standard... if the API you are trying to access is in unicode, then you have to use that when communicating with it. Do you not compile for unicode by default?

Generally speaking (very generally) it's as easy as using a compiler option or just placing #define UNICODE at the top of your program (before the includes), though if the project wasn't unicode in the first place, occasionally small adjustments may need to be made for it to compile properly (string literals, etc).

You'd have to be a little more specific about the who what why and where....

sanferno
Silver Member
Silver Member
Posts: 271
Joined: 2013 Nov 30, 18:40

Re: wstring, encoding or whatever is this Sh#t all about?!

Post by sanferno » 2016 Sep 13, 20:30

Kilmatead wrote:You'd have to be a little more specific about the who what why and where....
I know, that was an intro (I guess) :wink:

I'm using VS2012 with an unicode charset project.
I think that you could 'decrypt' some info about the issue here (see Shipman's reply, please):
https://geonet.esri.com/thread/36257

I've seen in the API's documentation this info regarding "CreateGeodatabase" function:
EXT_FILEGDB_API fgdbError FileGDBAPI::CreateGeodatabase (const std::wstring &path, Geodatabase &geodatabase)
Opens an existing 10.x file geodatabase.
I'm able to make it work. The thing is that, for instance, path variable is set (hardcoded) to L"name" and I should found in the executable folder a directory called "name.gdb", not "둨“name.gdb" as I do (or even worst). This problem gets sometimes even funnier because those two first chinese characters aren't always the same (although I type the same name).

If you're really free of time, you can download the API and its documentation here (about 50MB):
http://appsforms.esri.com/products/down ... oadid=1626

Kilmatead
Platinum Member
Platinum Member
Posts: 4569
Joined: 2008 Sep 30, 06:52
Location: Dublin

Re: wstring, encoding or whatever is this Sh#t all about?!

Post by Kilmatead » 2016 Sep 13, 21:17

Curiously, the last response (scroll to the bottom) to this stackoverflow question suggests that perhaps GeoNet's library was compiled with an older version of VS (i.e., 2010) where MS's implementation of std::wstring apparently has changed since then and newer VS versions are incompatible with it.

(While this sounds unbelievable, it would be something MS would do given how much they seem to love declaring everything in the universe to be "deprecated" on a yearly basis. One of the serious downsides of tying yourself to their insanity.)

In other words, either GeoNet haven't updated recently or you can try VS 2010 for better backwards compatibility (or at least find some older libraries to link against so the wchar_t you pass is bitwise the same as they receive). I assume this question on GeoNet forums is your own? (Maybe nobody but us likes Spaniards anymore?)

If they can't help you, what hope do poor sinners like us have? :D

sanferno
Silver Member
Silver Member
Posts: 271
Joined: 2013 Nov 30, 18:40

Re: wstring, encoding or whatever is this Sh#t all about?!

Post by sanferno » 2016 Sep 14, 10:43

Kilmatead wrote: I assume this question on GeoNet forums is your own? (Maybe nobody but us likes Spaniards anymore?)
Nope, it wasn't me.
As one native English speaker I meet said: most of English speakers doesn't bother with the rest of languages in the world (at least those more common), they visit countries not making the effor to learning, for instance, French nor Spanish... they just keep looking their belly button. :lol:
Kilmatead wrote:If they can't help you, what hope do poor sinners like us have? :D
I've tested with both with older and current API's version for VS2010-12 and it remains the same. It seems ESRI is going to release the new "File Geodatabase API" version 1.5 this autumn (VS2015 compatible), so I guess I'll wait for until that moment.
I'll continue looking the solution, if I find something, I'll let you know here. Thanks for your time. :beer:

Post Reply