Focal Point
Decoding Currency Code into a Currency Symbol.

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7747004476

January 21, 2015, 10:01 PM
David Briars
Decoding Currency Code into a Currency Symbol.
I have a file containing ISO 4217 Currency Codes, e.g., USD.

In this case I would like to print the Currency Symbol '$' in a HTML report.

I found several Focal Point threads discussing this topic, but none seemed to give a solution.

I also reviewed 'Extended Currency Symbol Display Options', but only four (4) currencies are available.

I found a chart at the Currency Symbols website apparently giving the hexadecimal number for each of the codes.


So I fired up some code, decoding the Currency Code into the hexadecimal number.
-* File CurrCodeSymbol.fex
-*
APP PREPENDPATH IBISAMP
DEFINE FILE GGSALES
-* Create Currency Codes test data.  
 CURR_CODE/A50 = DECODE SEQ_NO (1 'ALL'
                                2 'AFN'
    			     3 'ARS'
			     4 'AWG');
-* Decode Currency Code into a Currency Symbol
 CURR_SYMB/A50 = DECODE CURR_CODE ('ALL' '&|#x4c;&|#x65;&|#x6b;'
                                   'AFN' '&|#x60b;'
			        'ARS' '&|#x24;'
			        'AWG' '&|#x192;');
END
-*
TABLE FILE GGSALES
PRINT SEQ_NO
      CURR_CODE AS 'Currency,Code'
      CURR_SYMB AS 'Currency,Symbol'	  
IF SEQ_NO LE 4
ON TABLE SET STYLE *
 INCLUDE = ENInformationBuilders_Light1, $
 TYPE=REPORT, SIZE=12,$
 TYPE=TITLE,  JUSTIFY=CENTER,$
 TYPE=DATA,   JUSTIFY=CENTER,$
ENDSTYLE
END  



Requests for help:
* Before I go any further, does anyone have any thoughts on whether I am on the right track or not?
* Has anyone created a text file of codes/hex symbol numbers that they can share?
* I added the concatenation symbol after the ampersand in each of the numeric character references. I did this, so the WF parser wouldn't see the references as an amper variable. Is there a better way to handle the character reference?

This message has been edited. Last edited by: David Briars,




Pilot: WebFOCUS 8.2.06 Test: WebFOCUS 8.1.05M Prod: WebFOCUS 8.1.05M Server: Windows Server 2016/Tomcat Standalone Workstation: Windows 10/IE11+Edge Database: Oracle 12c, Netezza, & MS SQL Server 2019 Output: AHTML/XLSX/HTML/PDF/JSCHART Tools: WFDS, Repository Content, BI Portal Designer & ReportCaster
January 22, 2015, 10:28 AM
Francis Mariani
David, you mentioned the report is HTML. I would create a file containing the currency code and the HTML decimal code. I would do this by view-source of the Currency Symbols page you posted, then use a smart text editor (e.g. EditPlus) to clean up the table. The code for the required Master is fairly obvious. I would join to this file - it could be a flat file, a FOCUS DB or a DBMS table. I cannot post the edited file here - the html codes translate to currency codes even within code tags. I can send the file to you.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
January 22, 2015, 10:51 AM
David Briars
Thanks Francis.

Your refinements sound very good. I think also that this will get around my issue of having an '&variable', in the DECODE pairs.




Pilot: WebFOCUS 8.2.06 Test: WebFOCUS 8.1.05M Prod: WebFOCUS 8.1.05M Server: Windows Server 2016/Tomcat Standalone Workstation: Windows 10/IE11+Edge Database: Oracle 12c, Netezza, & MS SQL Server 2019 Output: AHTML/XLSX/HTML/PDF/JSCHART Tools: WFDS, Repository Content, BI Portal Designer & ReportCaster
January 22, 2015, 11:38 AM
Francis Mariani
Replace + with #

AFN Afghanistan                   Afghani                       &+x60b;   
ALL Albania                       Lek                           &+x6b;    
ARS Argentina                     Peso                          &+x24;    
AWG Aruba                         Guilder                       &+x192;   
AUD Australia                     Dollar                        &+x24;    
AZN Azerbaijan                    Manat                         &+x43d;   
BSD Bahamas                       Dollar                        &+x24;    
BBD Barbados                      Dollar                        &+x24;    
BYR Belarus                       Ruble                         &+x2e;    
BZD Belize                        Dollar                        &+x24;    
BMD Bermuda                       Dollar                        &+x24;    
BOB Bolivia                       Boliviano                     &+x62;    
BAM Bosnia and Herzegovina        Convertible Marka             &+x4d;    
BWP Botswana                      Pula                          &+x50;    
BRL Brazil                        Real                          &+x24;    
BND Brunei                        Darussalam Dollar             &+x24;    
BGN Bulgaria                      Lev                           &+x432;   
KHR Cambodia                      Riel                          &+x17db;  
CAD Canada                        Dollar                        &+x24;    
KYD Cayman                        Dollar                        &+x24;    
CLP Chile                         Peso                          &+x24;    
CNY China                         Yuan Renminbi                 &+xa5;    
COP Colombia                      Peso                          &+x24;    
CRC Costa Rica                    Colon                         &+x20a1;  
HRK Croatia                       Kuna                          &+x6e;    
CUP Cuba                          Peso                          &+x20b1;  
CZK Czech Republic                Koruna                        &+x10d;   
DKK Denmark                       Krone                         &+x72;    
DOP Dominican Republic            Peso                          &+x24;    
EGP Egypt                         Pound                         &+xa3;    
SVC El Salvador                   Colon                         &+x24;    
EEK Estonia                       Kroon                         &+x72;    
EUR Euro Member                   Euro                          &+x20ac;  
FKP Falkland Islands              Pound                         &+xa3;    
FJD Fiji                          Dollar                        &+x24;    
GHC Ghana                         Cedis                         &+xa2;    
GIP Gibraltar                     Pound                         &+xa3;    
GTQ Guatemala                     Quetzal                       &+x51;    
GGP Guernsey                      Pound                         &+xa3;    
GYD Guyana                        Dollar                        &+x24;    
HNL Honduras                      Lempira                       &+x4c;    
HKD Hong Kong                     Dollar                        &+x24;    
HUF Hungary                       Forint                        &+x74;    
ISK Iceland                       Krona                         &+x72;    
INR India                         Rupee                         &+x20B9;  
IDR Indonesia                     Rupiah                        &+x70;    
IRR Iran                          Rial                          &+xfdfc;  
IMP Isle of Man                   Pound                         &+xa3;    
ILS Israel                        Shekel                        &+x20aa;  
JMD Jamaica                       Dollar                        &+x24;    
JPY Japan                         Yen                           &+xa5;    
JEP Jersey                        Pound                         &+xa3;    
KZT Kazakhstan                    Tenge                         &+x432;   
KPW Korea (North)                 Won                           &+x20a9;  
KRW Korea (South)                 Won                           &+x20a9;  
KGS Kyrgyzstan                    Som                           &+x432;   
LAK Laos                          Kip                           &+x20ad;  
LVL Latvia                        Lat                           &+x73;    
LBP Lebanon                       Pound                         &+xa3;    
LRD Liberia                       Dollar                        &+x24;    
LTL Lithuania                     Litas                         &+x74;    
MKD Macedonia                     Denar                         &+x43d;   
MYR Malaysia                      Ringgit                       &+x4d;    
MUR Mauritius                     Rupee                         &+x20a8;  
MXN Mexico                        Peso                          &+x24;    
MNT Mongolia                      Tughrik                       &+x20ae;  
MZN Mozambique                    Metical                       &+x54;    
NAD Namibia                       Dollar                        &+x24;    
NPR Nepal                         Rupee                         &+x20a8;  
ANG Netherlands                   Antilles Guilder              &+x192;   
NZD New Zealand                   Dollar                        &+x24;    
NIO Nicaragua                     Cordoba                       &+x24;    
NGN Nigeria                       Naira                         &+x20a6;  
XCD No flag                       East Caribbean Dollar         &+x24;    
NOK Norway                        Krone                         &+x72;    
OMR Oman                          Rial                          &+xfdfc;  
PKR Pakistan                      Rupee                         &+x20a8;  
PAB Panama                        Balboa                        &+x2e;    
PYG Paraguay                      Guarani                       &+x73;    
PEN Peru                          Nuevo Sol                     &+x2e;    
PHP Philippines                   Peso                          &+x20b1;  
PLN Poland                        Zloty                         &+x142;   
QAR Qatar                         Riyal                         &+xfdfc;  
RON Romania                       New Leu                       &+x69;    
RUB Russia                        Ruble                         &+x431;   
SHP Saint Helena                  Pound                         &+xa3;    
SAR Saudi Arabia                  Riyal                         &+xfdfc;  
RSD Serbia                        Dinar                         &+x2e;    
SCR Seychelles                    Rupee                         &+x20a8;  
SGD Singapore                     Dollar                        &+x24;    
SBD Solomon Islands               Dollar                        &+x24;    
SOS Somalia                       Shilling                      &+x53;    
ZAR South Africa                  Rand                          &+x53;    
LKR Sri Lanka                     Rupee                         &+x20a8;  
SRD Suriname                      Dollar                        &+x24;    
SEK Sweden                        Krona                         &+x72;    
CHF Switzerland                   Franc                         &+x46;    
SYP Syria                         Pound                         &+xa3;    
TWD Taiwan                        New Dollar                    &+x24;    
THB Thailand                      Baht                          &+xe3f;   
TTD Trinidad and Tobago           Dollar                        &+x24;    
TRL Turkey                        Lira                          &+x20a4;  
TVD Tuvalu                        Dollar                        &+x24;    
UAH Ukraine                       Hryvna                        &+x20b4;  
GBP United Kingdom                Pound                         &+xa3;    
USD United States                 Dollar                        &+x24;    
UYU Uruguay                       Peso                          &+x55;    
UZS Uzbekistan                    Som                           &+x432;   
VEF Venezuela                     Bolivar Fuerte                &+x73;    
VND Viet Nam                      Dong                          &+x20ab;  
YER Yemen                         Rial                          &+xfdfc;  
ZWD Zimbabwe                      Dollar                        &+x24;    



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
January 22, 2015, 12:05 PM
Tony A
Not wanting to put a downer on this, but don't forget that some browsers will not display some symbols like the Indian Rupee - such as IE10.

Of course this may not be a problem for the list of currencies that you require, but in case someone else does.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
January 22, 2015, 12:38 PM
Francis Mariani
Apparently there are updates to Microsoft software to display the newish Rupee symbol. Hopefully they cover IE10.

Microsoft Support: An update to support the new currency symbol for the Indian Rupee in Windows Vista, in Windows Server 2008, in Windows 7 and in Windows Server 2008 R2


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
January 22, 2015, 12:44 PM
Francis Mariani
The table above uses hex values, we could also use decimal values.

E.G.
& # 8 3 7 7 ; or
& # x 2 0 B 9 ;


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
January 22, 2015, 03:06 PM
David Briars
JOINing to the 'currency file' worked like a champ. Definitely has advantages over the DECODE construct.

If I see an issue with how one of the hex values displays, I'll take a look at using a decimal value instead. For us, under IE9, both the hex and decimal displayed the Indian Rupee symbol AOK.

Thanks, again.