Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of libMiMic by
NyLPC_cUrlEncode.c
00001 #include "NyLPC_cUrlEncode.h" 00002 #include <stdarg.h> 00003 #include <ctype.h> 00004 00005 00006 NyLPC_TBool NyLPC_cUrlEncode_initialize(NyLPC_TcUrlEncode_t* i_inst) 00007 { 00008 i_inst->_len=0; 00009 return NyLPC_TBool_TRUE; 00010 } 00011 00012 00013 NyLPC_TcUrlEncode_ST NyLPC_cUrlEncode_decode(NyLPC_TcUrlEncode_t* i_inst,NyLPC_TChar c,NyLPC_TChar* out) 00014 { 00015 int t; 00016 if(c=='%'){ 00017 if(i_inst->_len!=0){ 00018 NyLPC_OnErrorGoto(Error); 00019 } 00020 i_inst->_len=1; 00021 return NyLPC_TcUrlEncode_ST_NEXT; 00022 }else{ 00023 switch(i_inst->_len){ 00024 case 0: 00025 *out=c; 00026 return NyLPC_TcUrlEncode_ST_DONE; 00027 case 1: 00028 if(!isxdigit((int)c)){ 00029 NyLPC_OnErrorGoto(Error); 00030 } 00031 t=NyLPC_ctox(c); 00032 i_inst->v=(NyLPC_TChar)t;//16進文字→HEX 00033 i_inst->_len++; 00034 return NyLPC_TcUrlEncode_ST_NEXT; 00035 case 2: 00036 if(!isxdigit((int)c)){ 00037 NyLPC_OnErrorGoto(Error); 00038 } 00039 t=NyLPC_ctox(c); 00040 *out=(NyLPC_TChar)((i_inst->v<<4) | t); 00041 i_inst->v=0; 00042 i_inst->_len=0; 00043 return NyLPC_TcUrlEncode_ST_DONE; 00044 default: 00045 NyLPC_OnErrorGoto(Error); 00046 } 00047 } 00048 Error: 00049 i_inst->v=0; 00050 i_inst->_len=0; 00051 return NyLPC_TcUrlEncode_ST_ERROR; 00052 }
Generated on Tue Jul 12 2022 16:22:59 by
