Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have to resort to <code>C</code> style strings, since this is what <code>CGContextShowTextAtPoint()</code> requires. In order to correctly handle the locale (the currency symbol changes with the locale) you must use <code>setlocale()</code>, then you format your string using <code>strfmon()</code> and finally you pass the string created with <code>strfmon(</code>) to <code>CGContextShowTextAtPoint()</code>.</p> <p>Documentation is available as follows from the terminal:</p> <pre><code>man 3 setlocale man 3 strfmon </code></pre> <p>EDIT/UPDATE: For your information, <code>strfmon()</code> internally uses <code>struct lconv</code>. The structure can be retrieved with the function <code>localeconv()</code>. See <code>man 3 localeconv</code> for a detailed description of the fields available in the structure.</p> <p>for instance, try the following simple C program setting different locales </p> <pre><code>#include &lt;stdio.h&gt; #include &lt;locale.h&gt; #include &lt;monetary.h&gt; int main(void) { char buf[BUFSIZ]; double val = 1234.567; /* use your current locale */ setlocale(LC_ALL, ""); /* uncomment the next line and try this to use italian locale */ /* setlocale(LC_ALL, "it_IT"); */ strfmon(buf, sizeof buf, "You owe me %n (%i)\n", val, val); fputs(buf, stdout); return 0; } </code></pre> <p>The following uses <code>localeconv()</code>:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;limits.h&gt; #include &lt;locale.h&gt; int main(void) { struct lconv l; int i; setlocale(LC_ALL, ""); l = *localeconv(); printf("decimal_point = [%s]\n", l.decimal_point); printf("thousands_sep = [%s]\n", l.thousands_sep); for (i = 0; l.grouping[i] != 0 &amp;&amp; l.grouping[i] != CHAR_MAX; i++) printf("grouping[%d] = [%d]\n", i, l.grouping[i]); printf("int_curr_symbol = [%s]\n", l.int_curr_symbol); printf("currency_symbol = [%s]\n", l.currency_symbol); printf("mon_decimal_point = [%s]\n", l.mon_decimal_point); printf("mon_thousands_sep = [%s]\n", l.mon_thousands_sep); printf("positive_sign = [%s]\n", l.positive_sign); printf("negative_sign = [%s]\n", l.negative_sign); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload