# Code () Function Error

**URL:** <https://the.fmsoup.org/t/code-function-error/331>\
**Category:** Questions\
**Tags:** code-function, error\
**Created:** [September 12, 2019, 9:38am UTC](https://the.fmsoup.org/t/code-function-error/331 "2019-09-12T09:38:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torsten](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/torsten/32/1574_2.png) [@Torsten](https://the.fmsoup.org/u/Torsten)\
**Post date:** [September 12, 2019, 9:38am UTC](https://the.fmsoup.org/t/code-function-error/331/1 "2019-09-12T09:38:30Z")

</div>

The Code () function delivers a less-than five digits block for the first character (leftmost) in a string.  
The documention text says 5 digits but the sample given further down on the same page contradicts it and FMP18 actually does it like described in the sample. No 5-digits block.

 ![Code%20Function%20Error](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/1X/1fe3561de209a3034c3705e849173a0f1483f878.png)

---

<div class="post-metadata">

**Author:** ![jormond](https://avatars.discourse-cdn.com/v4/letter/j/35a633/32.png) [@jormond](https://the.fmsoup.org/u/jormond)\
**Post date:** [September 12, 2019, 3:49pm UTC](https://the.fmsoup.org/t/code-function-error/331/2 "2019-09-12T15:49:45Z")

</div>

That would be expected behavior. There are 2 things in play here.

1. Unicode is interpreted from Right-to-Left in blocks of 5 characters, with leading zeros.
2. FileMaker cast the data type as a number, so the first character would drop the leading zeros.

Code ( “a” ) = 97  
Char ( 97 ) = a  
Char ( “00097” ) = a

---

<div class="post-metadata">

**Author:** ![Torsten](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/torsten/32/1574_2.png) [@Torsten](https://the.fmsoup.org/u/Torsten)\
**Post date:** [September 13, 2019, 8:45am UTC](https://the.fmsoup.org/t/code-function-error/331/3 "2019-09-13T08:45:46Z")

</div>

Thanks, Joshua!
