php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63326 Wrong currency format for sr_Latn locale
Submitted: 2012-10-21 10:31 UTC Modified: 2012-10-22 15:43 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: umpirsky at gmail dot com Assigned:
Status: Not a bug Package: intl (PECL)
PHP Version: 5.3.18 OS: Ubuntu
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: umpirsky at gmail dot com
New email:
PHP Version: OS:

 

 [2012-10-21 10:31 UTC] umpirsky at gmail dot com
Description:
------------
Money for sr_Latn locale is formatted like:

din. 33

for sr_Cyrl like:

551 дин.

Cyrl version is ok, Latn looks wrong, it should be:

33 din.

Test script:
---------------
<?php

$formatter = new \NumberFormatter('sr_Latn', \NumberFormatter::CURRENCY);
echo $formatter->formatCurrency(33, 'RSD');

Expected result:
----------------
33 din.

Actual result:
--------------
din. 33

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-10-22 15:42 UTC] cataphract@php.net
The bug, if any, is in ICU. See http://site.icu-project.org/bugs instead.

My results:

$ icuinfo 
<ICUINFO>
International Components for Unicode for C/C++
 Copyright (C) 2011, International Business Machines Corporation and others. All 
Rights Reserved. 
Compiled-Version: 4.8.1.1
Runtime-Version: 4.8.1.1
Compiled-Unicode-Version: 6.0
Runtime-Unicode-Version: 6.0
Platform: U_LINUX
Build: x86_64-pc-linux-gnu
C compiler: gcc
C++ compiler: g++
ICUDATA: icudt48l
Data Directory: 
ICU Initialization returned: U_ZERO_ERROR
Default locale: en_US
CLDR-Version: 2.0.1
Default converter: US-ASCII
Default TZ: Europe/Amsterdam
TZ data version: 2011k
Plugin file is: /usr/lib/x86_64-linux-gnu/icu/icuplugins48.txt
</ICUINFO>

$ cat a.c
#include <unicode/unum.h>
#include <unicode/ustdio.h>

int main()
{

	UNumberFormat *unf;
	UErrorCode status = 0;
	unf = unum_open(UNUM_CURRENCY, 0, 0, "sr_Latn", NULL, &status);
	if (U_FAILURE(status)) {
		fprintf(stderr, "unum_open: %s\n", u_errorName(status));
		return 1;
	}
	
	int32_t len;
	UChar result[256];
	len = unum_formatDoubleCurrency(unf, 33, (UChar[]) {'R', 'S', 'D', 0}, 
result,
			sizeof(result)/sizeof(*result), NULL, &status);
	if (U_FAILURE(status)) {
		fprintf(stderr, "unum_formatDoubleCurrency: %s\n", 
u_errorName(status));
		return 2;
	}
	UFILE *ustdout = u_finit(stdout, NULL, NULL);
	u_fprintf(ustdout, "%.*S", (int)len, result);
	return 0;
}
$ clang -licui18n -licuio a.c && ./a.out | hexdump -C
00000000  64 69 6e 2e 1a 33 33                              |din..33|
00000007
 [2012-10-22 15:43 UTC] cataphract@php.net
-Status: Open +Status: Not a bug
 [2012-10-22 15:43 UTC] cataphract@php.net
.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 05:01:30 2024 UTC