Copy link to clipboard
Copied
Anyone have any insight on setting an element's Alternate Text field using strings with accents (i.e. à, é, ô)?
I'm able to set the value using PDSElementSetAlt, but if the text is using accents (French, Spanish, German) then the accented characters are not showing up correctly.
For example, I have a P struct with "à la maison" as the textual content for the node. I then try to set the Alt Text for that tag using PDSElementSetAlt. The result is that it comes out as "‹ la maison" in the Alternate Text field in the Object Properties panel. The à gets saved as ‹
If I print out the string using AVAlertNote, I get the correct "à la maison" printed.
but Alt Text field does not show accented characters.
Here are the 3 lines of code that generate the Alert Note, and set the PDSElement's Alt Text:
sprintf(str,"Setting Alt Text for <%s> element to \"%s\"", nodeName, altText );
AVAlertNote(str);
PDSElementSetAlt( pdsElement, (ASUns8 *)altText, (ASInt32)strlen(altText));
I'm assuming this is because of the "ASUns8*" type for the string? Is there a way to set the text using a different character encoding that supports characters with accents?
PDSElementSetAltASText.
Copy link to clipboard
Copied
PDSElementSetAltASText.
Copy link to clipboard
Copied
That was it! Thank you so much! I had been worried about the whole 8-bit vs. 16-bit issues and hadn't even thought to look at ASText (in fact,
PDSElementSetAltASText is not even described in the Core API Reference I keep open – Tech Note #5191, Acrobat 6.0, March 2004). That will teach me to always use the latest...
For the record, here is my modified code that appears to work on the dozen or so test cases I've run so far:
sprintf(str,"Setting Alt Text for <%s> element to \"%s\"", nodeName, altText );
AVAlertNote(str);
ASText asTextAltText = ASTextFromEncoded(altText, kASRomanScript);
PDSElementSetAltASText( pdsElement, asTextAltText);