Code pages: Unicode strings, Macintosh, etc.

Another consideration is how Unicode property names are stored in the property ID 0 (the property name dictionary), which is not specified per se to use Unicode strings.

This is straightforward. Unicode officially has a code page value of 1200. To store Unicode values in the property name dictionary, use a code page value of 1200 for the whole property set (in property ID 1, of course), specified by the absence of the PROPSETFLAG_ANSI flag in IPropertySetStorage::Create. Note that this has the side effect of storing all string values in the property set in Unicode. In all code pages, the count found at the start of a VT_LPSTR s a byte count, not a character count. This is necessary to provide for smooth interoperability with down-level clients.

The compound file implementation of IPropertySetStorage creates all new property sets completely either in Unicode (code page 1200) or in the current system ANSI code page. This is controlled by the absence or presence of the PROPSETFLAG_ANSI flag in the grfFlags parameter of IPropertySetStorage::Create.

It is recommended that property sets be created or opened as Unicode, by not setting the PROPSETFLAG_ANSI flag in the grfFlags parameter of IPropertySetStorage::Create. It is also recommended that you avoid using VT_LPSTR values, and use VT_LPWSTR values instead. When the property set code page is Unicode, VT_LPSTR string values are converted to Unicode when stored, and back to multibyte string values when retrieved. When the code page of the property set is not Unicode, property names, VT_BSTR strings, and non-simple property values are converted to multibyte strings when stored, and converted back to Unicode when retrieved. If the property set code page is Unicode, VT_LPSTR string values are converted to Unicode when stored, and back to multibyte string values when retrieved.

The setting of the PROPSETFLAG_ANSI flag as reported through a call to IPropertyStorage::Stat simply reflects whether the underlying code page is not Unicode or is Unicode. Note, though, property ID 1 can be explicitly read to learn the code page.

Property ID 1 is accessible through IPropertyStorage::ReadMultiple. However, it is read-only, and may not be updated with WriteMultiple. Further, it may not be deleted with DeleteMultiple.