diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2018-11-04 00:30:57 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2018-11-04 14:49:11 +0100 |
commit | ed3f281ba9302d58644771082467983328643ff7 (patch) | |
tree | 48d1878ccf266cb3275e26bdbe7d51bab7c75c43 /doc | |
parent | a8b6fa08b743066693fe1da02985d0f5422b7d36 (diff) | |
download | weechat-ed3f281ba9302d58644771082467983328643ff7.zip |
api: add functions string_base_{encode,decode}, remove functions string_{encode,decode}_base64
Diffstat (limited to 'doc')
-rw-r--r-- | doc/en/weechat_plugin_api.en.adoc | 36 | ||||
-rw-r--r-- | doc/fr/weechat_plugin_api.fr.adoc | 38 | ||||
-rw-r--r-- | doc/it/weechat_plugin_api.it.adoc | 45 | ||||
-rw-r--r-- | doc/ja/weechat_plugin_api.ja.adoc | 43 |
4 files changed, 108 insertions, 54 deletions
diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc index 9ecbc9b81..98d8b47fd 100644 --- a/doc/en/weechat_plugin_api.en.adoc +++ b/doc/en/weechat_plugin_api.en.adoc @@ -1778,21 +1778,22 @@ str = weechat.string_remove_color(string, replacement) str = weechat.string_remove_color(my_string, "?") ---- -==== string_encode_base64 +==== string_base_encode -_WeeChat ≥ 0.3.2, updated in 2.4._ +_WeeChat ≥ 2.4._ -Encode a string in base64. +Encode a string in base 16, 32, or 64. Prototype: [source,C] ---- -int weechat_string_encode_base64 (const char *from, int length, char *to); +int weechat_string_base_encode (int base, const char *from, int length, char *to); ---- Arguments: +* _base_: 16, 32, or 64 * _from_: string to encode * _length_: length of string to encode (for example `strlen(from)`) * _to_: pointer to string to store result (must be long enough, result is @@ -1800,7 +1801,7 @@ Arguments: Return value: -* length of string stored in _*to_ (does not count final _\0_) +* length of string stored in _*to_ (does not count final `\0`), -1 if error C example: @@ -1808,43 +1809,52 @@ C example: ---- char *string = "abcdefgh", result[128]; int length; -length = weechat_string_encode_base64 (string, strlen (string), result); +length = weechat_string_base_encode (16, string, strlen (string), result); +/* length == 16, result == "6162636465666768" */ +length = weechat_string_base_encode (32, string, strlen (string), result); +/* length == 16, result == "MFRGGZDFMZTWQ===" */ +length = weechat_string_base_encode (64, string, strlen (string), result); /* length == 12, result == "YWJjZGVmZ2g=" */ ---- [NOTE] This function is not available in scripting API. -==== string_decode_base64 +==== string_base_decode -_WeeChat ≥ 0.3.2._ +_WeeChat ≥ 2.4._ -Decode a base64 string. +Decode a string encoded in base 16, 32, or 64. Prototype: [source,C] ---- -int weechat_string_decode_base64 (const char *from, char *to); +int weechat_string_base_decode (int base, const char *from, char *to); ---- Arguments: +* _base_: 16, 32, or 64 * _from_: string to decode * _to_: pointer to string to store result (must be long enough, result is shorter than initial string) Return value: -* length of string stored in _*to_ (does not count final _\0_) +* length of string stored in _*to_ (does not count final `\0`), -1 if error C example: [source,C] ---- -char *string = "YWJjZGVmZ2g=", result[128]; +char result[128]; int length; -length = weechat_string_decode_base64 (string, result); +length = weechat_string_base_decode (16, "6162636465666768", result); +/* length == 8, result == "abcdefgh" */ +length = weechat_string_base_decode (32, "MFRGGZDFMZTWQ===", result); +/* length == 8, result == "abcdefgh" */ +length = weechat_string_base_decode (64, "YWJjZGVmZ2g=", result); /* length == 8, result == "abcdefgh" */ ---- diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc index 5f3181dac..942ba06bd 100644 --- a/doc/fr/weechat_plugin_api.fr.adoc +++ b/doc/fr/weechat_plugin_api.fr.adoc @@ -1812,21 +1812,22 @@ str = weechat.string_remove_color(string, replacement) str = weechat.string_remove_color(ma_chaine, "?") ---- -==== string_encode_base64 +==== string_base_encode -_WeeChat ≥ 0.3.2, mis à jour dans la 2.4._ +_WeeChat ≥ 2.4._ -Encoder une chaîne en base64. +Encoder une chaîne en base 16, 32 ou 64. Prototype : [source,C] ---- -int weechat_string_encode_base64 (const char *from, int length, char *to); +int weechat_string_base_encode (int base, const char *from, int length, char *to); ---- Paramètres : +* _base_ : 16, 32 ou 64 * _from_ : chaîne à encoder * _length_ : longueur de chaîne à encoder (par exemple `strlen(from)`) * _to_ : pointeur vers la chaîne pour stocker le résultat (doit être @@ -1834,7 +1835,8 @@ Paramètres : Valeur de retour : -* longueur de la chaîne stockée dans _*to_ (ne compte pas le _\0_ final) +* longueur de la chaîne stockée dans _*to_ (ne compte pas le `\0` final), + -1 en cas d'erreur Exemple en C : @@ -1842,43 +1844,53 @@ Exemple en C : ---- char *string = "abcdefgh", result[128]; int length; -length = weechat_string_encode_base64 (string, strlen (string), result); +length = weechat_string_base_encode (16, string, strlen (string), result); +/* length == 16, result == "6162636465666768" */ +length = weechat_string_base_encode (32, string, strlen (string), result); +/* length == 16, result == "MFRGGZDFMZTWQ===" */ +length = weechat_string_base_encode (64, string, strlen (string), result); /* length == 12, result == "YWJjZGVmZ2g=" */ ---- [NOTE] Cette fonction n'est pas disponible dans l'API script. -==== string_decode_base64 +==== string_base_decode -_WeeChat ≥ 0.3.2._ +_WeeChat ≥ 2.4._ -Décoder une chaîne base64. +Décoder une chaîne encodée en base 16, 32 ou 64. Prototype : [source,C] ---- -int weechat_string_decode_base64 (const char *from, char *to); +int weechat_string_base_decode (int base, const char *from, char *to); ---- Paramètres : +* _base_ : 16, 32 ou 64 * _from_ : chaîne à décoder * _to_ : pointeur vers la chaîne pour stocker le résultat (doit être suffisamment long, le résultat est plus court que la chaîne initiale) Valeur de retour : -* longueur de la chaîne stockée dans _*to_ (ne compte pas le _\0_ final) +* longueur de la chaîne stockée dans _*to_ (ne compte pas le `\0` final), + -1 en cas d'erreur Exemple en C : [source,C] ---- -char *string = "YWJjZGVmZ2g=", result[128]; +char result[128]; int length; -length = weechat_string_decode_base64 (string, result); +length = weechat_string_base_decode (16, "6162636465666768", result); +/* length == 8, result == "abcdefgh" */ +length = weechat_string_base_decode (32, "MFRGGZDFMZTWQ===", result); +/* length == 8, result == "abcdefgh" */ +length = weechat_string_base_decode (64, "YWJjZGVmZ2g=", result); /* length == 8, result == "abcdefgh" */ ---- diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc index a0dd0988b..127fae44d 100644 --- a/doc/it/weechat_plugin_api.it.adoc +++ b/doc/it/weechat_plugin_api.it.adoc @@ -1851,22 +1851,24 @@ str = weechat.string_remove_color(string, replacement) str = weechat.string_remove_color(my_string, "?") ---- -==== string_encode_base64 +==== string_base_encode -// TRANSLATION MISSING -_WeeChat ≥ 0.3.2, updated in 2.4._ +_WeeChat ≥ 2.4._ -Codifica una stringa in base64. +// TRANSLATION MISSING +Encode a string in base 16, 32, or 64. Prototipo: [source,C] ---- -int weechat_string_encode_base64 (const char *from, int length, char *to); +int weechat_string_base_encode (int base, const char *from, int length, char *to); ---- Argomenti: +// TRANSLATION MISSING +* _base_: 16, 32, or 64 * _from_: stringa da codificare * _length_: lunghezza della stringa da codificare (ad esempio `strlen(from)`) * _to_: puntatore alla stringa per memorizzare il risultato (deve essere @@ -1874,7 +1876,9 @@ Argomenti: Valore restituito: -* lunghezza della stringa memorizzata in _*to_ (lo _\0_ finale non conta) +// TRANSLATION MISSING +* lunghezza della stringa memorizzata in _*to_ (lo `\0` finale non conta), + -1 if error Esempio in C: @@ -1882,43 +1886,56 @@ Esempio in C: ---- char *string = "abcdefgh", result[128]; int length; -length = weechat_string_encode_base64 (string, strlen (string), result); +length = weechat_string_base_encode (16, string, strlen (string), result); +/* length == 16, result == "6162636465666768" */ +length = weechat_string_base_encode (32, string, strlen (string), result); +/* length == 16, result == "MFRGGZDFMZTWQ===" */ +length = weechat_string_base_encode (64, string, strlen (string), result); /* length == 12, result == "YWJjZGVmZ2g=" */ ---- [NOTE] Questa funzione non è disponibile nelle API per lo scripting. -==== string_decode_base64 +==== string_base_decode -_WeeChat ≥ 0.3.2._ +_WeeChat ≥ 2.4._ -Decodifica una stringa in base64. +// TRANSLATION MISSING +Decode a string encoded in base 16, 32, or 64. Prototipo: [source,C] ---- -int weechat_string_decode_base64 (const char *from, char *to); +int weechat_string_base_decode (int base, const char *from, char *to); ---- Argomenti: +// TRANSLATION MISSING +* _base_: 16, 32, or 64 * _from_: stringa da decodificare * _to_: puntatore alla stringa per memorizzare il risultato (deve essere sufficientemente lunga, il risultato è più lungo della stringa iniziale) Valore restituito: -* lunghezza della stringa memorizzata in _*to_ (lo _\0_ finale non conta) +// TRANSLATION MISSING +* lunghezza della stringa memorizzata in _*to_ (lo `\0` finale non conta), + -1 if error Esempio in C: [source,C] ---- -char *string = "YWJjZGVmZ2g=", result[128]; +char result[128]; int length; -length = weechat_string_decode_base64 (string, result); +length = weechat_string_base_decode (16, "6162636465666768", result); +/* length == 8, result == "abcdefgh" */ +length = weechat_string_base_decode (32, "MFRGGZDFMZTWQ===", result); +/* length == 8, result == "abcdefgh" */ +length = weechat_string_base_decode (64, "YWJjZGVmZ2g=", result); /* length == 8, result == "abcdefgh" */ ---- diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc index 5ac11dfee..026131dd8 100644 --- a/doc/ja/weechat_plugin_api.ja.adoc +++ b/doc/ja/weechat_plugin_api.ja.adoc @@ -1784,22 +1784,24 @@ str = weechat.string_remove_color(string, replacement) str = weechat.string_remove_color(my_string, "?") ---- -==== string_encode_base64 +==== string_base_encode -// TRANSLATION MISSING -_WeeChat ≥ 0.3.2, updated in 2.4._ +_WeeChat バージョン 2.4 以上で利用可。_ -文字列を base64 でエンコード。 +// TRANSLATION MISSING +Encode a string in base 16, 32, or 64. プロトタイプ: [source,C] ---- -int weechat_string_encode_base64 (const char *from, int length, char *to); +int weechat_string_base_encode (int base, const char *from, int length, char *to); ---- 引数: +// TRANSLATION MISSING +* _base_: 16, 32, or 64 * _from_: エンコード元文字列 * _length_: エンコードする文字列の長さ (例えば `strlen(from)`) * _to_: エンコード結果を保存する文字列へのポインタ @@ -1807,7 +1809,8 @@ int weechat_string_encode_base64 (const char *from, int length, char *to); 戻り値: -* _*to_ に保存された文字列の長さ (最後の _\0_ は数えません) +// TRANSLATION MISSING +* _*to_ に保存された文字列の長さ (最後の `\0` は数えません), -1 if error C 言語での使用例: @@ -1815,43 +1818,55 @@ C 言語での使用例: ---- char *string = "abcdefgh", result[128]; int length; -length = weechat_string_encode_base64 (string, strlen (string), result); +length = weechat_string_base_encode (16, string, strlen (string), result); +/* length == 16, result == "6162636465666768" */ +length = weechat_string_base_encode (32, string, strlen (string), result); +/* length == 16, result == "MFRGGZDFMZTWQ===" */ +length = weechat_string_base_encode (64, string, strlen (string), result); /* length == 12, result == "YWJjZGVmZ2g=" */ ---- [NOTE] スクリプト API ではこの関数を利用できません。 -==== string_decode_base64 +==== string_base_decode -_WeeChat バージョン 0.3.2 以上で利用可。_ +_WeeChat バージョン 2.4 以上で利用可。_ -base64 文字列をデコード。 +// TRANSLATION MISSING +Decode a string encoded in base 16, 32, or 64. プロトタイプ: [source,C] ---- -int weechat_string_decode_base64 (const char *from, char *to); +int weechat_string_base_decode (int base, const char *from, char *to); ---- 引数: +// TRANSLATION MISSING +* _base_: 16, 32, or 64 * _from_: デコード元文字列 * _to_: デコード結果を保存する文字列へのポインタ (十分な領域を確保してください、結果はデコード元文字列よりも短くなります) 戻り値: -* _*to_ に保存された文字列の長さ (最後の _\0_ は数えません) +// TRANSLATION MISSING +* _*to_ に保存された文字列の長さ (最後の `\0` は数えません), -1 if error C 言語での使用例: [source,C] ---- -char *string = "YWJjZGVmZ2g=", result[128]; +char result[128]; int length; -length = weechat_string_decode_base64 (string, result); +length = weechat_string_base_decode (16, "6162636465666768", result); +/* length == 8, result == "abcdefgh" */ +length = weechat_string_base_decode (32, "MFRGGZDFMZTWQ===", result); +/* length == 8, result == "abcdefgh" */ +length = weechat_string_base_decode (64, "YWJjZGVmZ2g=", result); /* length == 8, result == "abcdefgh" */ ---- |