Hello,

I have an application where the amount is formatted with this function:

define("CURRENCY", "€");

function format_value($value, $decoding = false) {
	$curr = ($decoding) ? html_entity_decode(CURRENCY) : CURRENCY;
	$formatted = $curr." ".number_format($value, 2, ",", ".");
	return $formatted;
}

I use this function for presentation in a browser and also for a text type email. My problem is that this example is valid according w3 but it will not be decoded for the text mail.

I already played a while with ord() and some other functions but every combination is valid for w3 or isn't visible inside the mail.

Anyone an idea?

Thanks...

    Numeric entity instead?

    €

    But I believe you will need to convert back for a text email. Isn't that right?

      vaaaska wrote:

      Numeric entity instead?

      Right this is possible, but you can't identify/convert this in php.
      But maybe there is way?

        Right,

        multi_byte is an option but is not supported on all servers :bemused:

          😕

          ... I think thats why people so often use this kind of strings for currencies:

          EUR, USD, GBP...

            vaaaska wrote:

            Nope. But most hosts I've dealt with were happy to install it. There's certainly a work around...read the comments (I think it's in there).

            comments? for which function?

              vaaaska,

              you have to retire now:

              I'll retire at 1,000

                Thanks I saw this kind of structure in the comments:

                define("CURRENCY", "€");
                
                function format_value($value, $decoding = true) {
                	if ($decoding) {
                		switch (ord(CURRENCY)) {
                			case "128":
                			$curr = "&#".8364.";";
                			break;
                			default:
                			$curr= CURRENCY;
                		}
                	} else {
                		$curr= CURRENCY;
                	}
                	$formatted = $curr." ".number_format($value, 2, ",", ".");
                	return $formatted;
                }
                
                
                  2 months later
                  PHPFAQ wrote:

                  ... you're funny... :evilgrin:

                    I dunno how non-ASCII characters are supposed to be rendered in plain-text emails (I haven't read RFC2822 in a while). Perhaps the appropriate conversion is that € => EUR one.

                    ... actually I just checked. The standard states that "The body of a message is simply lines of US-ASCII characters."

                      Yes, the problem is inside the encoding iso-8859-1 there is no euro sign. There are two ways:

                      using the word "euro" or using another encoding :-(

                        Well, as you said, most people use EUR (And they use it partly because that's the international standard. ISO 4217, if I recall.)

                          Write a Reply...