/** ************************************************************************** * \brief Escape string to be XML valid * Allowed chars are defined by the above function isAllowedChar() * Invalid chars are escaped using non standard '?XX' notation. * NOTE: We cannot trust VLC internal Web encoding functions * because they are not able to encode and decode some rare utf-8 * characters properly. Also, we don't control exactly when they are * called (from this module). *****************************************************************************/ static int escapeToXml( char **ppsz_encoded, const char *psz_url ) { char *psz_iter, *psz_tmp; /* Count number of unallowed characters in psz_url */ size_t i_num = 0, i_len = 0; for( psz_iter = (char*) psz_url; *psz_iter; ++psz_iter ) { if( isAllowedChar( *psz_iter ) ) { i_len++; } else { i_len++; i_num++; } } /* Special case */ if( i_num == 0 ) { *ppsz_encoded = malloc( i_len + 1 ); memcpy( *ppsz_encoded, psz_url, i_len + 1 ); return VLC_SUCCESS; } /* Copy string, replacing invalid characters */ char *psz_ret = malloc( i_len + 3*i_num + 2 ); if( !psz_ret ) return VLC_ENOMEM; for( psz_iter = (char*) psz_url, psz_tmp = psz_ret; *psz_iter; ++psz_iter, ++psz_tmp ) { if( isAllowedChar( *psz_iter ) ) { *psz_tmp = *psz_iter; } else { *(psz_tmp++) = '?'; snprintf( psz_tmp, 3, "%02x", ( *psz_iter & 0x000000FF ) ); psz_tmp++; } } *psz_tmp = '\0'; /* Return success */ *ppsz_encoded = psz_ret; return VLC_SUCCESS; }
void CExtendedInput_Item_Char::keyPressed(const int key) { int value = CRCInput::getUnicodeValue(key); if (value != -1) { if (isAllowedChar((char)value)) { *data = (char)value; g_RCInput->postMsg( CRCInput::RC_right, 0 ); } } else { unsigned int pos = getCharID( *data ); if (key==CRCInput::RC_up) { if(pos<allowedChars.size()-1) { *data = allowedChars[pos+1]; } else { *data = allowedChars[0]; } } else if (key==CRCInput::RC_down) { if(pos>0) { *data = allowedChars[pos-1]; } else { *data = allowedChars[allowedChars.size()-1]; } } } }