{"action":"created","issue":{"url":"https://api.github.com/repos/itead/ITEADLIB_Arduino_Nextion/issues/38","repository_url":"https://api.github.com/repos/itead/ITEADLIB_Arduino_Nextion","labels_url":"https://api.github.com/repos/itead/ITEADLIB_Arduino_Nextion/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/itead/ITEADLIB_Arduino_Nextion/issues/38/comments","events_url":"https://api.github.com/repos/itead/ITEADLIB_Arduino_Nextion/issues/38/events","html_url":"https://github.com/itead/ITEADLIB_Arduino_Nextion/issues/38","id":215228214,"node_id":"MDU6SXNzdWUyMTUyMjgyMTQ=","number":38,"title":"utoa not included in standard C/C++ lib","user":{"login":"hahnicity","id":3508859,"node_id":"MDQ6VXNlcjM1MDg4NTk=","avatar_url":"https://avatars2.githubusercontent.com/u/3508859?v=4","gravatar_id":"","url":"https://api.github.com/users/hahnicity","html_url":"https://github.com/hahnicity","followers_url":"https://api.github.com/users/hahnicity/followers","following_url":"https://api.github.com/users/hahnicity/following{/other_user}","gists_url":"https://api.github.com/users/hahnicity/gists{/gist_id}","starred_url":"https://api.github.com/users/hahnicity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hahnicity/subscriptions","organizations_url":"https://api.github.com/users/hahnicity/orgs","repos_url":"https://api.github.com/users/hahnicity/repos","events_url":"https://api.github.com/users/hahnicity/events{/privacy}","received_events_url":"https://api.github.com/users/hahnicity/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-03-18T23:07:56Z","updated_at":"2018-12-10T16:00:04Z","closed_at":null,"author_association":"NONE","body":"We're working on an Intel Edison which uses GNU libc/c++ and we've been trying to compile our nextion code but it doesn't work because `utoa` is not included in the base C/C++ lib. The only workaround I can currently think of is to modify the library to include `utoa`. Do you have any other suggestions?"},"comment":{"url":"https://api.github.com/repos/itead/ITEADLIB_Arduino_Nextion/issues/comments/445867568","html_url":"https://github.com/itead/ITEADLIB_Arduino_Nextion/issues/38#issuecomment-445867568","issue_url":"https://api.github.com/repos/itead/ITEADLIB_Arduino_Nextion/issues/38","id":445867568,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NTg2NzU2OA==","user":{"login":"Pharap","id":2933055,"node_id":"MDQ6VXNlcjI5MzMwNTU=","avatar_url":"https://avatars1.githubusercontent.com/u/2933055?v=4","gravatar_id":"","url":"https://api.github.com/users/Pharap","html_url":"https://github.com/Pharap","followers_url":"https://api.github.com/users/Pharap/followers","following_url":"https://api.github.com/users/Pharap/following{/other_user}","gists_url":"https://api.github.com/users/Pharap/gists{/gist_id}","starred_url":"https://api.github.com/users/Pharap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pharap/subscriptions","organizations_url":"https://api.github.com/users/Pharap/orgs","repos_url":"https://api.github.com/users/Pharap/repos","events_url":"https://api.github.com/users/Pharap/events{/privacy}","received_events_url":"https://api.github.com/users/Pharap/received_events","type":"User","site_admin":false},"created_at":"2018-12-10T16:00:04Z","updated_at":"2018-12-10T16:00:04Z","author_association":"NONE","body":"Sorry to rake up such an old issue, but `utoa` (nonstandard) can be implemented with `sprintf``/`std::sprintf` (standard):\r\n```cpp\r\nchar * utoa(unsigned int value, char * str, int radix)\r\n{\r\n\tconst char * format = nullptr;\r\n\r\n\tswitch(radix)\r\n\t{\r\n\t\tcase 8:\r\n\t\t\tformat = \"%o\";\r\n\t\t\tbreak;\r\n\t\tcase 10:\r\n\t\t\tformat = \"%u\";\r\n\t\t\tbreak;\r\n\t\tcase 16:\r\n\t\t\tformat = \"%x\";\r\n\t\t\tbreak;\r\n\t}\r\n\r\n\tif(format == nullptr)\r\n\t\treturn str;\r\n\r\n\tint size = std::sprintf(str, format, value);\r\n\treturn &str[size];\r\n}\r\n```\r\n\r\nAlternatively, if you only need radix 10 support and you can't afford `sprintf` then you can do:\r\n```cpp\r\nchar * utoa(unsigned int value, char * str, int radix)\r\n{\r\n\tif(radix == 10)\r\n\t\twhile(value > 0)\r\n\t\t{\r\n\t\t\tunsigned int digit = value % 10;\r\n\t\t\tvalue /= 10;\r\n\t\t\t*str = static_cast<char>('0' + digit);\r\n\t\t\t++str;\r\n\t\t}\r\n\r\n\treturn str;\r\n}\r\n```"}}
{"actor":{"display_login":"Pharap"}}