Guest_imported
New member
- Jan 1, 1970
- 0
I am trying to write a script that replaces all the occurences of ansi color codes
in a variable with their html equivalent hex color codes ( <font colour=#000000> ).
All was working fine, until i realised that not only are the standard colours used, but
from time to time, to make a word or number stand out, the "bold" ansi code is sent.
Example:
[36mYou are currently level [1m82[0m and are about [1m95[0m% to level [1m83[0m.
This line appears as the following:
<font color=#008080>You are currently level <font color=#00FFFF>82<font color=#008080>
and are about <font color=#00FFFF>95<font color=#008080>% to level <font color=#00FFFF>83<font
color=#008080>.
This is the same with all colors available... so in the case of yellow:
[33mYou are carrying [1m323 gold[0;37m 7 silver[0;33m coins
<font color=#808000>You are carrying <font color=#FFFF00>323 gold <font color=#FFFFFF> 7 silver
<font color=#808000>coins.
[36m = dark cyan (#008080)
adding the "bold" ansi code changes the color to bright cyan (#00FFFF)
[33m = dark yellow (#808000)
adding the "bold" ansi code changes the color to bright yellow (#FFFF00)
the [37m (or [0;37m) is the "dark white (or gray)" (#C0C0C0) code, but since the "bold" code
was present before hand, it is bold, and therefore comes out as bright white (#FFFFFF).
In this case, the [1m bold code is used each time, but there are occurences where the bold
code is only used once, and there are multiple color changes until it is disabled (by "[0m"
.
SO it may happen that the line will apear like this:
[33mYou are carrying [1m323 gold[37m 7 silver[0;33m coins
Without the BOLD code after the dark white colour change, and therefore it needs to remember
that the bold code was present, and hasnt been disabled, even though the color has changed.
Since I'm no expert, I'm having great difficulty in even contemplating how this could be done
(or if it is even possible), and any help would be greatly appreciated.
I can be contacted on any of the following, or via this board.
MSN Messenger: shaunchurch@hotmail.com
ICQ#: 24868483
Thanks,
-Shaun
in a variable with their html equivalent hex color codes ( <font colour=#000000> ).
All was working fine, until i realised that not only are the standard colours used, but
from time to time, to make a word or number stand out, the "bold" ansi code is sent.
Example:
[36mYou are currently level [1m82[0m and are about [1m95[0m% to level [1m83[0m.
This line appears as the following:
<font color=#008080>You are currently level <font color=#00FFFF>82<font color=#008080>
and are about <font color=#00FFFF>95<font color=#008080>% to level <font color=#00FFFF>83<font
color=#008080>.
This is the same with all colors available... so in the case of yellow:
[33mYou are carrying [1m323 gold[0;37m 7 silver[0;33m coins
<font color=#808000>You are carrying <font color=#FFFF00>323 gold <font color=#FFFFFF> 7 silver
<font color=#808000>coins.
[36m = dark cyan (#008080)
adding the "bold" ansi code changes the color to bright cyan (#00FFFF)
[33m = dark yellow (#808000)
adding the "bold" ansi code changes the color to bright yellow (#FFFF00)
the [37m (or [0;37m) is the "dark white (or gray)" (#C0C0C0) code, but since the "bold" code
was present before hand, it is bold, and therefore comes out as bright white (#FFFFFF).
In this case, the [1m bold code is used each time, but there are occurences where the bold
code is only used once, and there are multiple color changes until it is disabled (by "[0m"
SO it may happen that the line will apear like this:
[33mYou are carrying [1m323 gold[37m 7 silver[0;33m coins
Without the BOLD code after the dark white colour change, and therefore it needs to remember
that the bold code was present, and hasnt been disabled, even though the color has changed.
Since I'm no expert, I'm having great difficulty in even contemplating how this could be done
(or if it is even possible), and any help would be greatly appreciated.
I can be contacted on any of the following, or via this board.
MSN Messenger: shaunchurch@hotmail.com
ICQ#: 24868483
Thanks,
-Shaun