diff options
author | Dean Karn <Dean.Karn@metricaid.com> | 2016-09-11 16:37:03 +0300 |
---|---|---|
committer | Dean Karn <Dean.Karn@metricaid.com> | 2016-09-11 16:37:03 +0300 |
commit | 5b6f32dd67efd00b8d58b98ea7d6c8b7fdff6e9b (patch) | |
tree | 19a0522646eafcdc8bc4a83b67fdaa68da814cc4 /fr_CM | |
parent | aaae900248cc5de78e3c73c1ec3b3cc6dac92f9b (diff) |
add check for multibyte chars after switching from []byte to string
Diffstat (limited to 'fr_CM')
-rw-r--r-- | fr_CM/fr_CM.go | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/fr_CM/fr_CM.go b/fr_CM/fr_CM.go index 00f04c1c..e9315ddc 100644 --- a/fr_CM/fr_CM.go +++ b/fr_CM/fr_CM.go @@ -18,7 +18,7 @@ type fr_CM struct { group string minus string percent string - percentSuffix []byte + percentSuffix string perMille string timeSeparator string inifinity string @@ -58,7 +58,7 @@ func New() locales.Translator { timeSeparator: ":", inifinity: "∞", currencies: []string{"ADP ", "AED ", "AFA ", "AFN ", "ALK ", "ALL ", "AMD ", "ANG ", "AOA ", "AOK ", "AON ", "AOR ", "ARA ", "ARL ", "ARM ", "ARP ", "ARS ", "ATS ", "AUD ", "AWG ", "AZM ", "AZN ", "BAD ", "BAM ", "BAN ", "BBD ", "BDT ", "BEC ", "BEF ", "BEL ", "BGL ", "BGM ", "BGN ", "BGO ", "BHD ", "BIF ", "BMD ", "BND ", "BOB ", "BOL ", "BOP ", "BOV ", "BRB ", "BRC ", "BRE ", "BRL ", "BRN ", "BRR ", "BRZ ", "BSD ", "BTN ", "BUK ", "BWP ", "BYB ", "BYR ", "BZD ", "CAD ", "CDF ", "CHE ", "CHF ", "CHW ", "CLE ", "CLF ", "CLP ", "CNX ", "CNY ", "COP ", "COU ", "CRC ", "CSD ", "CSK ", "CUC ", "CUP ", "CVE ", "CYP ", "CZK ", "DDM ", "DEM ", "DJF ", "DKK ", "DOP ", "DZD ", "ECS ", "ECV ", "EEK ", "EGP ", "ERN ", "ESA ", "ESB ", "ESP ", "ETB ", "EUR ", "FIM ", "FJD ", "FKP ", "FRF ", "GBP ", "GEK ", "GEL ", "GHC ", "GHS ", "GIP ", "GMD ", "GNF ", "GNS ", "GQE ", "GRD ", "GTQ ", "GWE ", "GWP ", "GYD ", "HKD ", "HNL ", "HRD ", "HRK ", "HTG ", "HUF ", "IDR ", "IEP ", "ILP ", "ILR ", "ILS ", "INR ", "IQD ", "IRR ", "ISJ ", "ISK ", "ITL ", "JMD ", "JOD ", "JPY ", "KES ", "KGS ", "KHR ", "KMF ", "KPW ", "KRH ", "KRO ", "KRW ", "KWD ", "KYD ", "KZT ", "LAK ", "LBP ", "LKR ", "LRD ", "LSL ", "LTL ", "LTT ", "LUC ", "LUF ", "LUL ", "LVL ", "LVR ", "LYD ", "MAD ", "MAF ", "MCF ", "MDC ", "MDL ", "MGA ", "MGF ", "MKD ", "MKN ", "MLF ", "MMK ", "MNT ", "MOP ", "MRO ", "MTL ", "MTP ", "MUR ", "MVP ", "MVR ", "MWK ", "MXN ", "MXP ", "MXV ", "MYR ", "MZE ", "MZM ", "MZN ", "NAD ", "NGN ", "NIC ", "NIO ", "NLG ", "NOK ", "NPR ", "NZD ", "OMR ", "PAB ", "PEI ", "PEN ", "PES ", "PGK ", "PHP ", "PKR ", "PLN ", "PLZ ", "PTE ", "PYG ", "QAR ", "RHD ", "ROL ", "RON ", "RSD ", "RUB ", "RUR ", "RWF ", "SAR ", "SBD ", "SCR ", "SDD ", "SDG ", "SDP ", "SEK ", "SGD ", "SHP ", "SIT ", "SKK ", "SLL ", "SOS ", "SRD ", "SRG ", "SSP ", "STD ", "SUR ", "SVC ", "SYP ", "SZL ", "THB ", "TJR ", "TJS ", "TMM ", "TMT ", "TND ", "TOP ", "TPE ", "TRL ", "TRY ", "TTD ", "TWD ", "TZS ", "UAH ", "UAK ", "UGS ", "UGX ", "USD ", "USN ", "USS ", "UYI ", "UYP ", "UYU ", "UZS ", "VEB ", "VEF ", "VND ", "VNN ", "VUV ", "WST ", "XAF ", "XAG ", "XAU ", "XBA ", "XBB ", "XBC ", "XBD ", "XCD ", "XDR ", "XEU ", "XFO ", "XFU ", "XOF ", "XPD ", "XPF ", "XPT ", "XRE ", "XSU ", "XTS ", "XUA ", "XXX ", "YDD ", "YER ", "YUD ", "YUM ", "YUN ", "YUR ", "ZAL ", "ZAR ", "ZMK ", "ZMW ", "ZRN ", "ZRZ ", "ZWD ", "ZWL ", "ZWR "}, - percentSuffix: []byte{0xc2, 0xa0}, + percentSuffix: " ", currencyPositiveSuffix: " ", currencyNegativePrefix: "(", currencyNegativeSuffix: " )", @@ -75,7 +75,7 @@ func New() locales.Translator { erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, - timezones: map[string]string{"LHDT": "heure d’été de Lord Howe", "IST": "heure de l’Inde", "AST": "heure normale de l’Atlantique", "SRT": "heure du Suriname", "MYT": "heure de la Malaisie", "HAST": "heure normale d’Hawaii - Aléoutiennes", "HAT": "heure d’été de Terre-Neuve", "OESZ": "heure d’été d’Europe de l’Est", "WAST": "heure d’été d’Afrique de l’Ouest", "HNT": "heure normale de Terre-Neuve", "HKT": "heure normale de Hong Kong", "EST": "heure normale de l’Est nord-américain", "GFT": "heure de la Guyane française", "ECT": "heure de l’Équateur", "LHST": "heure normale de Lord Howe", "MDT": "heure d’été de Macao", "CLST": "heure d’été du Chili", "PST": "heure normale du Pacifique nord-américain", "ADT": "heure d’été de l’Atlantique", "GYT": "heure du Guyana", "TMT": "heure normale du Turkménistan", "WAT": "heure normale d’Afrique de l’Ouest", "∅∅∅": "heure d’été des Açores", "AKST": "heure normale de l’Alaska", "CST": "heure normale du centre nord-américain", "MST": "heure normale de Macao", "HKST": "heure d’été de Hong Kong", "CAT": "heure normale d’Afrique centrale", "AEST": "heure normale de l’Est de l’Australie", "VET": "heure du Venezuela", "SAST": "heure normale d’Afrique méridionale", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "AWST": "heure normale de l’Ouest de l’Australie", "CLT": "heure normale du Chili", "UYT": "heure normale de l’Uruguay", "BOT": "heure de Bolivie", "CHADT": "heure d’été des îles Chatham", "ACST": "heure normale du centre de l’Australie", "EDT": "heure d’été de l’Est", "WIB": "heure de l’Ouest indonésien", "CHAST": "heure normale des îles Chatham", "SGT": "heure de Singapour", "WEZ": "heure normale d’Europe de l’Ouest", "GMT": "heure moyenne de Greenwich", "AEDT": "heure d’été de l’Est de l’Australie", "JST": "heure normale du Japon", "PDT": "heure d’été du Pacifique", "MESZ": "heure d’été d’Europe centrale", "ARST": "heure d’été de l’Argentine", "ART": "heure normale d’Argentine", "WITA": "heure du Centre indonésien", "JDT": "heure d’été du Japon", "CDT": "heure d’été du Centre", "AWDT": "heure d’été de l’Ouest de l’Australie", "EAT": "heure normale d’Afrique de l’Est", "OEZ": "heure normale d’Europe de l’Est", "WARST": "heure d’été de l’Ouest argentin", "WESZ": "heure d’été d’Europe de l’Ouest", "COT": "heure normale de Colombie", "ACDT": "heure d’été du centre de l’Australie", "TMST": "heure d’été du Turkménistan", "UYST": "heure d’été de l’Uruguay", "NZST": "heure normale de la Nouvelle-Zélande", "NZDT": "heure d’été de la Nouvelle-Zélande", "WART": "heure normale de l’Ouest argentin", "ACWST": "heure normale du centre-ouest de l’Australie", "AKDT": "heure d’été de l’Alaska", "MEZ": "heure normale d’Europe centrale", "ChST": "heure des Chamorro", "WIT": "heure de l’Est indonésien", "COST": "heure d’été de Colombie", "BT": "heure du Bhoutan", "ACWDT": "heure d’été du centre-ouest de l’Australie"}, + timezones: map[string]string{"SGT": "heure de Singapour", "ACST": "heure normale du centre de l’Australie", "GYT": "heure du Guyana", "MDT": "heure d’été des Rocheuses", "MYT": "heure de la Malaisie", "GMT": "heure moyenne de Greenwich", "ACWDT": "heure d’été du centre-ouest de l’Australie", "WARST": "heure d’été de l’Ouest argentin", "ACDT": "heure d’été du centre de l’Australie", "AEST": "heure normale de l’Est de l’Australie", "∅∅∅": "heure d’été des Açores", "HKT": "heure normale de Hong Kong", "SRT": "heure du Suriname", "TMST": "heure d’été du Turkménistan", "SAST": "heure normale d’Afrique méridionale", "HKST": "heure d’été de Hong Kong", "ChST": "heure des Chamorro", "COST": "heure d’été de Colombie", "UYT": "heure normale de l’Uruguay", "UYST": "heure d’été de l’Uruguay", "BT": "heure du Bhoutan", "COT": "heure normale de Colombie", "WEZ": "heure normale d’Europe de l’Ouest", "CLST": "heure d’été du Chili", "AWST": "heure normale de l’Ouest de l’Australie", "TMT": "heure normale du Turkménistan", "ART": "heure normale d’Argentine", "WESZ": "heure d’été d’Europe de l’Ouest", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "CHAST": "heure normale des îles Chatham", "MESZ": "heure d’été d’Europe centrale", "AEDT": "heure d’été de l’Est de l’Australie", "MST": "heure normale des Rocheuses", "WIT": "heure de l’Est indonésien", "CAT": "heure normale d’Afrique centrale", "NZST": "heure normale de la Nouvelle-Zélande", "NZDT": "heure d’été de la Nouvelle-Zélande", "EAT": "heure normale d’Afrique de l’Est", "JST": "heure normale du Japon", "MEZ": "heure normale d’Europe centrale", "AWDT": "heure d’été de l’Ouest de l’Australie", "CDT": "heure d’été du Centre", "LHST": "heure normale de Lord Howe", "WAST": "heure d’été d’Afrique de l’Ouest", "WART": "heure normale de l’Ouest argentin", "AST": "heure normale de l’Atlantique", "GFT": "heure de la Guyane française", "EST": "heure normale de l’Est nord-américain", "EDT": "heure d’été de l’Est", "WAT": "heure normale d’Afrique de l’Ouest", "HAT": "heure d’été de Terre-Neuve", "WITA": "heure du Centre indonésien", "ARST": "heure d’été de l’Argentine", "HAST": "heure normale d’Hawaii - Aléoutiennes", "CST": "heure normale du centre nord-américain", "HNT": "heure normale de Terre-Neuve", "AKDT": "heure d’été de l’Alaska", "ACWST": "heure normale du centre-ouest de l’Australie", "LHDT": "heure d’été de Lord Howe", "WIB": "heure de l’Ouest indonésien", "ADT": "heure d’été de l’Atlantique", "PST": "heure normale du Pacifique nord-américain", "BOT": "heure de Bolivie", "OESZ": "heure d’été d’Europe de l’Est", "VET": "heure du Venezuela", "IST": "heure de l’Inde", "JDT": "heure d’été du Japon", "CLT": "heure normale du Chili", "AKST": "heure normale de l’Alaska", "OEZ": "heure normale d’Europe de l’Est", "PDT": "heure d’été du Pacifique", "ECT": "heure de l’Équateur", "CHADT": "heure d’été des îles Chatham"}, } } @@ -211,7 +211,8 @@ func (fr *fr_CM) WeekdaysWide() []string { } // FmtNumber returns 'num' with digits/precision of 'v' for 'fr_CM' and handles both Whole and Real numbers based on 'v' -func (fr *fr_CM) FmtNumber(num float64, v uint64) (results string) { +func (fr *fr_CM) FmtNumber(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) l := len(s) + len(fr.decimal) + len(fr.group)*len(s[:len(s)-int(v)-1])/3 count := 0 @@ -224,7 +225,6 @@ func (fr *fr_CM) FmtNumber(num float64, v uint64) (results string) { for j := len(fr.decimal) - 1; j >= 0; j-- { b = append(b, fr.decimal[j]) } - inWhole = true continue } @@ -234,7 +234,6 @@ func (fr *fr_CM) FmtNumber(num float64, v uint64) (results string) { for j := len(fr.group) - 1; j >= 0; j-- { b = append(b, fr.group[j]) } - count = 1 } else { count++ @@ -255,13 +254,12 @@ func (fr *fr_CM) FmtNumber(num float64, v uint64) (results string) { b[i], b[j] = b[j], b[i] } - results = string(b) - return + return string(b) } // FmtPercent returns 'num' with digits/precision of 'v' for 'fr_CM' and handles both Whole and Real numbers based on 'v' // NOTE: 'num' passed into FmtPercent is assumed to be in percent already -func (fr *fr_CM) FmtPercent(num float64, v uint64) (results string) { +func (fr *fr_CM) FmtPercent(num float64, v uint64) string { s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) l := len(s) + len(fr.decimal) b := make([]byte, 0, l) @@ -272,7 +270,6 @@ func (fr *fr_CM) FmtPercent(num float64, v uint64) (results string) { for j := len(fr.decimal) - 1; j >= 0; j-- { b = append(b, fr.decimal[j]) } - continue } @@ -294,12 +291,11 @@ func (fr *fr_CM) FmtPercent(num float64, v uint64) (results string) { b = append(b, fr.percent...) - results = string(b) - return + return string(b) } // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CM' -func (fr *fr_CM) FmtCurrency(num float64, v uint64, currency currency.Type) (results string) { +func (fr *fr_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string { s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) symbol := fr.currencies[currency] @@ -314,7 +310,6 @@ func (fr *fr_CM) FmtCurrency(num float64, v uint64, currency currency.Type) (res for j := len(fr.decimal) - 1; j >= 0; j-- { b = append(b, fr.decimal[j]) } - inWhole = true continue } @@ -324,7 +319,6 @@ func (fr *fr_CM) FmtCurrency(num float64, v uint64, currency currency.Type) (res for j := len(fr.group) - 1; j >= 0; j-- { b = append(b, fr.group[j]) } - count = 1 } else { count++ @@ -360,13 +354,12 @@ func (fr *fr_CM) FmtCurrency(num float64, v uint64, currency currency.Type) (res b = append(b, symbol...) - results = string(b) - return + return string(b) } // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CM' // in accounting notation. -func (fr *fr_CM) FmtAccounting(num float64, v uint64, currency currency.Type) (results string) { +func (fr *fr_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string { s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) symbol := fr.currencies[currency] @@ -381,7 +374,6 @@ func (fr *fr_CM) FmtAccounting(num float64, v uint64, currency currency.Type) (r for j := len(fr.decimal) - 1; j >= 0; j-- { b = append(b, fr.decimal[j]) } - inWhole = true continue } @@ -391,7 +383,6 @@ func (fr *fr_CM) FmtAccounting(num float64, v uint64, currency currency.Type) (r for j := len(fr.group) - 1; j >= 0; j-- { b = append(b, fr.group[j]) } - count = 1 } else { count++ @@ -432,8 +423,7 @@ func (fr *fr_CM) FmtAccounting(num float64, v uint64, currency currency.Type) (r b = append(b, symbol...) } - results = string(b) - return + return string(b) } // FmtDateShort returns the short date representation of 't' for 'fr_CM' |