How to convert ISO 4217 code to currency code in swift - ios

Is there any way to convert ISO 4217 numeric code to currency code like this:
978 -> EUR
I checked Apple docs and I found only how can I take EUR
Here is what I searched:
Locale
Locale spesific

There is no API available in iOS (or any other Apple OS) that provides information about ISO 4217 codes. You will need to create your own mapping.
I would find a definitive list of codes (perhaps Wikipedia or the ISO website) and put the codes in a plist file. Then write a simple Locale extension that lets you get a currency code from a 4217 code.

As rmaddy suggested I made a plist with iso4217 codes and did my own mapping, here is the playground for anyone who wants it.

Related

How can I parse a particular representation of ISO 8601 timestamp (one without any whitespaces) using DateTimeFormatter?

I am trying to parse an ISO 8601 timestamp which looks like this: "20220603T054813Z". My supervisor gave me this timestamp asking me to parse it (she found it on wiki under the ISO-8601 page) but I couldnt find information regarding this type of timestamp anywhere else.
I am trying to parse it using a LocalDateTime instance and using a pre-defined format but I cant find any. Using any of the classes doesnt work neither do the pre-defined formatters for ISO 8601 timestamps. There's no example in the documentation that explains how to handle this particular case and that makes me wonder if this is a valid ISO 8601 case. It does work with my own created format but I am writing a logic to handle ISO 8601 cases without me having to define a custom format, as much as possible. atleast for the ISO 8601 timestamps. Is this a valid ISO 8601 timestamp even? Because usually they have separators for date and time.
Is there a way to handle timestamps like these, which doesnt have any separators or whitespaces, with a pre-defined formatter? Maybe i am missing something. Any help would be appreciated, thanks!

How to convert price in string into value in swift iOS SDK

Please guide me an issue, I am getting a price from the server as below (as an example)
two hundred forty-two
and I want to convert this value into 242.00.
Please guide me on how to convert it.
I know we can use .spellOut with NumberFormatter for converting value into String but can't find a way to do the above.
Alright, you have managed to nerd-snipe me.
I've implemented a number string parser as a Swift package. I don't expect you to bring in a whole package just to do this, but you might find some inspiration here:
https://github.com/daltonclaybrook/NumberParser

How would I convert ISO 8601 durations into a formatted string in Lua?

I've been using Youtube API v3 (yes, I know, it wasn't meant for Lua) recently, but when I need to convert an ISO 8601 duration into a formatted string, nothing on the web helps. I've been googling all over the place, to search for a specific library that could help with this sort of thing, but unfortunately, there is NONE for Lua. There is thousands of libraries out there for other languages except Lua.
And now, it seems I'm stuck with string patterns which I don't even know how to use. So how else would I go about doing this task?
Example of an ISO 8601 duration:
PT3M33S
I want to convert it into something like this:
3:33
If you don't want to parse the whole ISO 8601 specification, try this code:
s="PT3M33S"
t=s:gsub("^.-(%d+)M(%d+)S","%1:%2")
print(t)
It uses Lua pattern matching. The pattern reads: skip everything until a run of digits followed by an M and then find a run of digits followed by an S. Capture both runs of digits and use them in the replacement pattern.
If you want to extract both numbers, use this:
s="PT3M33S"
M,S=s:match("^.-(%d+)M(%d+)S")
print(M,S)

What are most actual locale & language ISO standards nowdays?

Can't get what ISO standards are actual nowadays for locales and languages. Where i can find such info?
I want to standardize languages and locales in my project.
I found the 639 standard for languages, but it is said that it is obsolete. Should I use 639-1 then? Should I use ISO 3166-2 for country codes then, to make locales by myself?
ISO 639 is the way to go for language codes: it is a 'superset' of standards for language codes with different lengths. Two-letter language codes, for example, can be found in ISO 639-1. You will have to decide if ISO 639-1 covers all languages that you need or not: if not, switch to ISO 639-2 or 639-3 (although even ISO 639-3 does not cover all languages in the world yet).
The 'obsolete' info that you saw most likely refers to the list that is kept on the w3c website: language codes do change from time to time.
See also this question for a more detailed answer - although I do not agree with all details given there.
To build your locale just combine language and country code (from ISO 3166), as you suggested. Two letter codes are more common than three letter codes: use them if they support all locales that you need.
The most authoritative guidance on this topic is IETF BCP 47, which recommends that you use the shortest code that is available for a language. So if both a two-letter code (ISO 639-1) and a three-letter code (ISO 639-2) are available, IETF BCP 47 recommends that you use the two-letter code.

Is there an iso standard for Currency Symbols?

I need to know the iso standard of Currency Symbols?
iso-4217 seems not covering this point.
The ISO only covers the 3 letter currency codes, and not the extended symbols.
If you like to have all the symbols then you can check it out here: http://www.xe.com/symbols.php
Not sure there is an ISO standard for currency symbols, e.g., £, $, etc. ISO-4217 is all about EUR, USD, GBP, etc. I guess this is the standard, as it is more consistent in how currency is shown and differentiates between currencies better.
Although not a standard, this may help: http://www.xe.com/symbols.php
You can download the new ISO codes and Symbols with Unicode fonts from below link :
https://drive.google.com/file/d/0B5DVIZeIMrCQMGRYT3NFd05CSGM/edit?usp=sharing

Resources