File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -73,3 +73,19 @@ static SYM: u8 = 0;
73
73
74
74
The next thing to note is that each interned string symbol is one byte in size (because ` static SYM ` has type ` u8 ` ).
75
75
Thanks to this the addresses of the symbols are consecutive: 0, 1, 2, etc.
76
+
77
+ ## Encoding
78
+
79
+ Storing strings as-is in symbol names can cause compatibility problems, since it can contain any arbitrary character. For example:
80
+
81
+ - The ` '@' ` character can't be used in symbol names because it's reserved for denoting symbol versions/
82
+ - The double-quote character ` '"' ` causes issues with escaping if you use it with ` sym ` inside an ` asm!() ` call.
83
+
84
+ To deal with this, strings are encoded to bytes as UTF-8, and then the bytes are hex-encoded.
85
+ The symbol is prefixed with ` __defmt_hex_ ` to denote it's is hex-encoded, and to allow for future expansion.
86
+
87
+
88
+ ``` rust
89
+ #[export_name = " __defmt_hex_55534220636f6e74726f6c6c6572206973207265616479" ]
90
+ static SYM : u8 = 0 ;
91
+ ```
You can’t perform that action at this time.
0 commit comments