📄 strings.c
字号:
else TRY_LONGCHAR( "¥", 5, "¥" ) else TRY_LONGCHAR( "¦", 8, "¦" ) else TRY_LONGCHAR( "§", 6, "§" ) else TRY_LONGCHAR( "¨", 5, "¨" ) else TRY_LONGCHAR( "©", 6, "©" ) else TRY_LONGCHAR( "ª", 6, "ª" ) else TRY_LONGCHAR( "«", 7, "«" ) else TRY_LONGCHAR( "¬", 5, "¬" ) else TRY_LONGCHAR( "­", 5, "" ) else TRY_LONGCHAR( "®", 5, "®" ) else TRY_LONGCHAR( "™", 7, "™" ) else TRY_LONGCHAR( "¯", 6, "¯" ) else TRY_LONGCHAR( "°", 5, "°" ) else TRY_LONGCHAR( "±", 8, "±" ) else TRY_LONGCHAR( "²", 6, "²" ) else TRY_LONGCHAR( "³", 6, "³" ) else TRY_LONGCHAR( "´", 7, "´" ) else TRY_LONGCHAR( "µ", 7, "µ" ) else TRY_LONGCHAR( "¶", 6, "¶" ) else TRY_LONGCHAR( "·", 8, "·" ) else TRY_LONGCHAR( "¸", 7, "¸" ) else TRY_LONGCHAR( "¹", 6, "¹" ) else TRY_LONGCHAR( "º", 6, "º" ) else TRY_LONGCHAR( "»", 7, "»" ) else TRY_LONGCHAR( "¼", 8, "¼" ) else TRY_LONGCHAR( "½", 8, "½" ) else TRY_LONGCHAR( "¾", 8, "¾" ) else TRY_LONGCHAR( "¿", 8, "¿" ) else TRY_LONGCHAR( "×", 7, "×" ) else TRY_LONGCHAR( "÷", 8, "÷" ) else TRY_LONGCHAR( "Œ", 7, "Œ" ) else TRY_LONGCHAR( "œ", 7, "œ" ) else TRY_LONGCHAR( "Š", 8, "Š" ) else TRY_LONGCHAR( "š", 8, "š" ) else TRY_LONGCHAR( "Ÿ", 6, "Ÿ" ) else TRY_LONGCHAR( "ˆ", 6, "ˆ" ) else TRY_LONGCHAR( "˜", 7, "˜" ) else TRY_LONGCHAR( "–", 7, "–" ) else TRY_LONGCHAR( "—", 7, "—" ) else TRY_LONGCHAR( "‘", 7, "‘" ) else TRY_LONGCHAR( "’", 7, "’" ) else TRY_LONGCHAR( "‚", 7, "‚" ) else TRY_LONGCHAR( "“", 7, "“" ) else TRY_LONGCHAR( "”", 7, "”" ) else TRY_LONGCHAR( "„", 7, "„" ) else TRY_LONGCHAR( "†", 8, "†" ) else TRY_LONGCHAR( "‡", 8, "‡" ) else TRY_LONGCHAR( "…", 8, "…" ) else TRY_LONGCHAR( "‰", 8, "‰" ) else TRY_LONGCHAR( "‹", 8, "‹" ) else TRY_LONGCHAR( "›", 8, "›" ) else TRY_LONGCHAR( "€", 6, "€" ) else { *p_pos = *psz_value; psz_value++; } } else { *p_pos = *psz_value; psz_value++; } p_pos++; } *p_pos = '\0';}/** * Converts '<', '>', '\"', '\'' and '&' to their html entities * \param psz_content simple element content that is to be converted */char *convert_xml_special_chars( const char *psz_content ){ char *psz_temp = malloc( 6 * strlen( psz_content ) + 1 ); const char *p_from = psz_content; char *p_to = psz_temp; while ( *p_from ) { if ( *p_from == '<' ) { strcpy( p_to, "<" ); p_to += 4; } else if ( *p_from == '>' ) { strcpy( p_to, ">" ); p_to += 4; } else if ( *p_from == '&' ) { strcpy( p_to, "&" ); p_to += 5; } else if( *p_from == '\"' ) { strcpy( p_to, """ ); p_to += 6; } else if( *p_from == '\'' ) { strcpy( p_to, "'" ); p_to += 6; } else { *p_to = *p_from; p_to++; } p_from++; } *p_to = '\0'; return psz_temp;}/* Base64 encoding */char *vlc_b64_encode_binary( const uint8_t *src, size_t i_src ){ static const char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; char *ret = malloc( ( i_src + 4 ) * 4 / 3 ); char *dst = ret; if( dst == NULL ) return NULL; while( i_src > 0 ) { /* pops (up to) 3 bytes of input, push 4 bytes */ uint32_t v; /* 1/3 -> 1/4 */ v = *src++ << 24; *dst++ = b64[v >> 26]; v = v << 6; /* 2/3 -> 2/4 */ if( i_src >= 2 ) v |= *src++ << 22; *dst++ = b64[v >> 26]; v = v << 6; /* 3/3 -> 3/4 */ if( i_src >= 3 ) v |= *src++ << 20; // 3/3 *dst++ = ( i_src >= 2 ) ? b64[v >> 26] : '='; // 3/4 v = v << 6; /* -> 4/4 */ *dst++ = ( i_src >= 3 ) ? b64[v >> 26] : '='; // 4/4 if( i_src <= 3 ) break; i_src -= 3; } *dst = '\0'; return ret;}char *vlc_b64_encode( const char *src ){ if( src ) return vlc_b64_encode_binary( (const uint8_t*)src, strlen(src) ); else return vlc_b64_encode_binary( (const uint8_t*)"", 0 );}/* Base64 decoding */size_t vlc_b64_decode_binary_to_buffer( uint8_t *p_dst, size_t i_dst, const char *p_src ){ static const int b64[256] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 00-0F */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 10-1F */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63, /* 20-2F */ 52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1, /* 30-3F */ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, /* 40-4F */ 15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1, /* 50-5F */ -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, /* 60-6F */ 41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1, /* 70-7F */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 80-8F */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 90-9F */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* A0-AF */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* B0-BF */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* C0-CF */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* D0-DF */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* E0-EF */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 /* F0-FF */ }; uint8_t *p_start = p_dst; uint8_t *p = (uint8_t *)p_src; int i_level; int i_last; for( i_level = 0, i_last = 0; (size_t)( p_dst - p_start ) < i_dst && *p != '\0'; p++ ) { const int c = b64[(unsigned int)*p]; if( c == -1 ) continue; switch( i_level ) { case 0: i_level++; break; case 1: *p_dst++ = ( i_last << 2 ) | ( ( c >> 4)&0x03 ); i_level++; break; case 2: *p_dst++ = ( ( i_last << 4 )&0xf0 ) | ( ( c >> 2 )&0x0f ); i_level++; break; case 3: *p_dst++ = ( ( i_last &0x03 ) << 6 ) | c; i_level = 0; } i_last = c; } return p_dst - p_start;}size_t vlc_b64_decode_binary( uint8_t **pp_dst, const char *psz_src ){ const int i_src = strlen( psz_src ); uint8_t *p_dst; *pp_dst = p_dst = malloc( i_src ); if( !p_dst ) return 0; return vlc_b64_decode_binary_to_buffer( p_dst, i_src, psz_src );}char *vlc_b64_decode( const char *psz_src ){ const int i_src = strlen( psz_src ); char *p_dst = malloc( i_src + 1 ); size_t i_dst; if( !p_dst ) return NULL; i_dst = vlc_b64_decode_binary_to_buffer( (uint8_t*)p_dst, i_src, psz_src ); p_dst[i_dst] = '\0'; return p_dst;}/**************************************************************************** * String formating functions ****************************************************************************/char *str_format_time( const char *tformat ){ char buffer[255]; time_t curtime; struct tm loctime; /* Get the current time. */ curtime = time( NULL ); /* Convert it to local time representation. */ localtime_r( &curtime, &loctime ); strftime( buffer, 255, tformat, &loctime ); return strdup( buffer );}#define INSERT_STRING( string ) \ if( string != NULL ) \ { \ int len = strlen( string ); \ dst = realloc( dst, i_size = i_size + len );\ memcpy( (dst+d), string, len ); \ d += len; \ free( string ); \ } \ else \ { \ *(dst+d) = '-'; \ d++; \ } \/* same than INSERT_STRING, except that string won't be freed */#define INSERT_STRING_NO_FREE( string ) \ { \ int len = strlen( string ); \ dst = realloc( dst, i_size = i_size + len );\ memcpy( dst+d, string, len ); \ d += len; \ }char *__str_format_meta( vlc_object_t *p_object, const char *string ){ const char *s = string; int b_is_format = 0; int b_empty_if_na = 0; char buf[10]; int i_size = strlen( string ) + 1; /* +1 to store '\0' */ char *dst = strdup( string ); if( !dst ) return NULL; int d = 0; playlist_t *p_playlist = pl_Yield( p_object ); input_thread_t *p_input = playlist_CurrentInput( p_playlist ); input_item_t *p_item = NULL; pl_Release( p_object ); if( p_input ) { p_item = input_GetItem(p_input); } while( *s ) { if( b_is_format ) { switch( *s ) { case 'a': if( p_item ) { INSERT_STRING( input_item_GetArtist( p_item ) ); } break; case 'b': if( p_item ) { INSERT_STRING( input_item_GetAlbum( p_item ) ); } break; case 'c': if( p_item ) { INSERT_STRING( input_item_GetCopyright( p_item ) ); } break; case 'd': if( p_item ) { INSERT_STRING( input_item_GetDescription( p_item ) ); } break; case 'e': if( p_item ) { INSERT_STRING( input_item_GetEncodedBy( p_item ) ); } break; case 'f': if( p_item && p_item->p_stats ) { snprintf( buf, 10, "%d", p_item->p_stats->i_displayed_pictures ); } else { sprintf( buf, b_empty_if_na ? "" : "-" ); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -