WoW API type: ValidChatMessageCharacters

From AddOn Studio
Revision as of 04:49, 15 August 2023 by Move page script (talk | contribs) (Move page script moved page ValidChatMessageCharacters to ValidChatMessageCharacters without leaving a redirect)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

API types

SendChatMessage cannot send all characters (or better call it 'bytes')!
Of course normal text - you would type in a custom channel - is supported, but some characters you might want to send by an addon can cause an error or - even worse - disconnect the player.

These are the characters that appear to be allowed for "msg" in SendChatMessage("msg"{,"type"{,"lang"{,"channel"}}}).

Allowed Characters[edit]


(use strchar(charID) to construct a char out of its decimal representation and strbyte("text" [, index]) to do the reverse thing)

ID Printout [by ChatFrame1:AddMessage(strchar(ID))] Note
0 none (terminates string) complete message ignored (not sent)
1 - 9 ? ok
10 new line (line feed) DISCONNECT
11 - 12 ? ok
13 new line (carriage return) ok
14 - 31 ? ok
32 - 123 standard ASCII ok (don't forget the character sequences '%t' and '%f': they will be replaced by your target's / focus's name or something like "<no target/focus>" - or a localized equivalent)
124 | ERROR "invalid escape code in chat message" (causes DISCONNECTs in patch 3.1.3)
125 - 126 standard ASCII ok
127 ? ok
128 - 255 ? ERROR "chat message must be UTF-8 text" possible

Notes[edit]

I tested each character by sending it to a custom channel named "test". Then I converted the received character to its ID and compared it with the original ID.
Especially on a byte-per-byte basis SendChatMessage has its restrictions (beside the 255 character - better say byte - thing).

Be very careful with splitting a UTF-8 text! You can end up with unexpected UTF-8 errors.

According to UTF-8: the error described above is not a big problem if your addon doesn't split a UTF-8 character into its byte-parts (I had the problem while automatically splitting messages that exceeded the maximum of 255 bytes!)

SendAddonMessage does not have any of those byte problems (except 0000 0000 and forbidden "\t" in prefix).