# PARSE\_CURRENCY

**The function PARSE\_CURRENCY takes a string and returns a currency.**

This function parses a [Currency](../../variable-data-types/the-currency-variable-data-type) from a [string](../../variable-data-types/the-text-variable-data-type) such as **"$1.00"**. If the input string cannot be parsed into a Currency, PARSE\_CURRENCY will return a Currency of zero U.S. dollars and a precision of two, See [Working with Numbers and Currency in Airscript](../../airscript/working-with-numbers-and-currency) for more details.

#### Declaration

```javascript
PARSE_CURRENCY(currency_string, locale) -> currency
```

#### Parameters

**currency\_string** (required, type: _string_) A string representing a currency.

**locale** (optional, type: _string_, default: **"en-US"**) The locale to use when parsing a currency symbol. For example, the string **"$1.00"** will be parsed as one U.S. dollar given a locale of **"en-US"**, but will be parsed as one Canadian dollar when given a locale of \*\*"en-CA".\*\*Locale must match a valid [LCID String](https://www.science.co.il/language/Locale-codes.php).

#### Return Values

**currency** (type: _currency_) A Currency with an amount/code that is parsed from **currency\_string**, and an appropriate precision for the world currency that was parsed.

#### Examples

By default, when the **locale** parameter is omitted, the currency will be parsed using a locale of **"en-US"**.

```javascript
PARSE_CURRENCY("$1.00") -> {  
  amount: 100,  
  code: "USD",  
  precision: 2  
}
```

With a locale of **"en-CA"**, the dollar sign will be interpreted as Canadian dollars rather than U.S. dollars.

```javascript
PARSE_CURRENCY("$1.00", "CAD") -> {  
  amount: 100,  
  code: "CAD",  
  precision: 2  
}
```

If there is no currency symbol in the input string, U.S. dollars will be assumed.

```javascript
PARSE_CURRENCY("1.00", "CAD") -> {  
  amount: 100,  
  code: "USD",  
  precision: 2  
}
```

Regardless of the locale provided, the Euro symbol (€) will always be interpreted as Euros. The locale will be used only for disambiguation.

```javascript
PARSE_CURRENCY("€1.00") -> {   
  amount: 100,  
  code: "EUR",  
  precision: 2  
}  
PARSE_CURRENCY("€1.00", "en-CA") -> {   
  amount: 100,  
  code: "EUR",  
  precision: 2  
}
```

If a currency cannot be parsed, PARSE\_CURRENCY will return a value of zero U.S. dollars.

```javascript
PARSE_CURRENCY("Not a currency") -> {   
  amount: 0,  
  code: "USD",  
  precision: 2  
}
```

This is true regardless of the provided locale.

```javascript
PARSE_CURRENCY("Not a currency", "en-CA") -> {  
  amount: 0,  
  code: "USD",  
  precision: 2  
}
```

#### Discussion

The PARSE\_CURRENCY function is the logical opposite of the [FORMAT\_CURRENCY](format_currency) function. In most cases, formatting, and then parsing a [Currency](../../variable-data-types/the-currency-variable-data-type) will return the original value. However, when there is ambiguity as to which world currency a symbol refers to, this may not be the case. For example, formatting, and then parsing Canadian dollars with a locale of **"en-US"** will return a Currency in U.S. dollars.

```javascript
PARSE_CURRENCY(FORMAT_CURRENCY(CURRENCY(100, "CAD"))) -> {  
  amount: 100,  
  code: "USD",  
  precision: 2  
}
```
