Aller au contenu

« IRC Colors en JavaScript » : différence entre les versions

aucun résumé des modifications
(Page créée avec « ==IRC Color Code == {| class="wikitable" |- |Number |Name |- |00 |white / blanc |- |01 |black / noir |- |02 |blue (navy) / bleu marine |- |03 |green / vert |- |04 |red /... »)
 
Aucun résumé des modifications
 
(6 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
== Generator ==
https://www.wiki-irc.com/colormirctojs.html
==IRC Color Code ==
==IRC Color Code ==


Ligne 60 : Ligne 63 :
Red text on a blue background would be:
Red text on a blue background would be:


<code>bot.say("#canal", "\x0304,02Example\x03")</code>
<syntaxhighlight lang="javascript">bot.say("#canal", "\x0304,02Example\x03")</syntaxhighlight>


==Other formatting==
==Other formatting==
Ligne 87 : Ligne 90 :
|}
|}


== Function JavaScript converter ==
<syntaxhighlight lang="javascript">
function formattingColorIRC(str) {
    // color
    str = str.replace(/\x03/g, "\\x03" );
   
    // bold
    str = str.replace(/\x02/g, "\\x02" );
   
    // italic
    str = str.replace(/\x1D/g, "\\x1D" );
   
    // underline
    str = str.replace(/\x1F/g, "\\x1F" );
   
    // swap background and foreground colors
    str = str.replace(/\x16/g, "\\x16" );
   
    return str;
}
   
   
formattingColorIRC("�0,4test"); //Result=\x030,4test
</syntaxhighlight>


==Mots clés==
==Mots clés==
control characters, IRC colors, IRC colours, caret notation
control characters, IRC colors, IRC colours, caret notation, irc colors javascript, converter irc colors for irc bot javascript or tcl