[TxMt] tm_dialog: TextField content output utf-8 encoded?
Allan Odgaard
throw-away-1 at macromates.com
Tue Oct 31 00:35:06 UTC 2006
On 31. Oct 2006, at 00:43, Hans-Joerg Bibiko wrote:
>>> [...] Would it be possible to output the content à la
>> I will switch to the XML property list format (as output) -- I
>> used the current because it's more readable and compact, thus
>> easier for testing etc.
> Well, by my opinion it would be nice to have both output formats
> (in UTF-8).
>
> The xml property list is perfect, but if you want to write a short
> bash script with a tm_dialog it could be a bit elaborate.
The problem is that the old-style ASCII format is only supported for
reading by the OS. The old output came from calling ‘description’ on
the dictionary, which gives something almost but not exactly like the
old-style format.
So I would need to embed my own pretty-printer if it should be
supported.
I should also add that technically the old-style format does not
support dates, booleans, and integers, these are all converted to
strings, which is not ideal.
For the simple case, an option is to pipe the output through ‘pl’,
though you will get the problem with non-ASCII, you can use
‘__CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100 pl’, which will
still use \Unnnn, but at least it will be correct, e.g.:
echo '{ foo = "æblegrød"; }'| \
__CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100 pl
{foo = "\U00e6blegr\U00f8d"; }
And for the records, if you do not set the user encoding:
echo '{ foo = "æblegrød"; }'| \
pl
{foo = "\U221a\U00b6blegr\U221a\U220fd"; }
What we could maybe do was a bash function which parsed the tm_dialog
result and exported the values as environment values / bash arrays or
similar. I can see how the XML output basically makes it infeasible
to use tm_dialog from a shell script w/o using a scripting language
with an XML/plist parser.
More information about the textmate
mailing list