Tinderbox Forum

German umlauts and exportedString

I am a Tinderbox beginner and have a problem with the German umlauts. When I use the following stamp:

$Body=exportedString(this,$Text);runCommand(“echo " +”’" + $Body + “’” + " | pbcopy“)

instead of the umlauts (öäü) I only get √∂√§√º

Is there a way to display the umlauts correctly?

Where do you want to use the umlauts? As I recall exportedString() was something added back in v5 before the app re-write with a unicode base, so why the need to use it?

BTW, if you want to show code examples without the forum software messing with the quote symbols, either but a back-tick before and after the example or for longer bits of code put 3 back-ticks on a separate line both before and after the example, for this sort of effect:

$Example = "some text";

Looking further, this seems to related to the encoding of strings passed via runCommand(). In other words, this works:


But this fails (as you describe above):

runCommand("echo " +"'" + $Body + "'" + " | pbcopy");

This looks to be a UTF-8 encoding-related issue.

Lacking documentation of the innards of runCommand() I’ll flag it for @eastgate.

Here’s what I did.

  1. I made a string attribute named $MyCommand
  2. I made a note named Hückel and Gödel
  3. I made a template note named template containing the text
echo "^title^"
  1. I added a rule to Hückel and Gödel:

I did this two-step because I kept getting tangled up in bad quotation pairs and escape sequences. This way, I see exactly what the shell sees.

I did not encounter encoding problems.

Note from the pbcopy man page:

pbcopy and pbpaste use locale environment variables to determine the
encoding to be used for input and output. For example, absent other
locale settings, setting the environment variable LANG=en_US.UTF-8 will
cause pbcopy and pbpaste to use UTF-8 for input and output. If an
encoding cannot be determined from the locale, the standard C encoding
will be used. Use of UTF-8 is recommended. Note that by default the
Terminal application uses the UTF-8 encoding and automatically sets the
appropriate locale environment variable.

Checking and setting environment variables in macOS

I’m note sure that does the same as the OP, plus the second line returns an error as the command (or the bare title string) is not understood. If I make $MyCommand the

Plus, the starting context was $Text, not $Name, so ^text^ doesn’t work like ^title^ as—by default—you get HTML paragraph mark-up.

I also tried:


But but the output is Hückel and Gödel.

So what encoding is Tinderbox passing to runCommand? It seems like it’s necessary to store the LANG Environment variable, re-set the LANG to en-US.UTF-8, process the rest of the above script, then re-set the LANG.

I’ll admit I’m unclear why we are using this method to place something on the pasteboard, aside from the encoding issue.

I believe we’re passing UTF8, and H√ºckel looks like what you see if you take UTF8 and assume it is MacRoman.

1 Like

Thanks for checking.
I don’t want to bore anyone here, but if I use the following rule
$Body=exportedString(this, $Text); runCommand("echo " + $Body + " > test.txt")

then I get a file that contains all the umlauts. On the command line I can use

cat test.txt | pbcopy

to place the content correctly on the pasteboard.

but if I apply (and this is only for testing purposes) the following rule:

$Body=exportedString(this, $Text); 
runCommand("echo " + $Body + " > test.txt; cat test.txt | pbcopy" );

I have my umlaut problem again.

1 Like

OK, but I ask again, what is the aim here. Is this just something that doesn’t seem to work, or is there a need to place data on the Mac clipboard. If the latter, there are other approaches. Otherwise, I think it’s a known problem, for now, so there’s no need to keep reporting.

If you want to keep experimenting…

I think the answer lies in the observation above encoding issue. In you last example above all processes are happeing in a Terminal session with misaligned encoding. Have you tried setting the LANG environment as part of your call to the shell? (I should add that I’ve not tried it myself as this lies outside my area of expertise). :slight_smile: