Aller au contenu

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

495 octets ajoutés ,  23 juin 2020 à 15:57
aucun résumé des modifications
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 87 : Ligne 87 :
|}
|}


== JavaScript converter ==
<pre>
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
</pre>


==Mots clés==
==Mots clés==
control characters, IRC colors, IRC colours, caret notation, irc colors javascript
control characters, IRC colors, IRC colours, caret notation, irc colors javascript