# translate-c: add wide string literal support · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/1ed8c54cd349497adb264b0502783a6422e4f2d1)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 1ed8c54cd349497adb264b0502783a6422e4f2d1

Requested commit: 1ed8c54cd349497adb264b0502783a6422e4f2d1

Commit: 1ed8c54cd349497adb264b0502783a6422e4f2d1

Tree: 813be35e4f0e0745451c97474970322acdc79e40

Author: Evan Haas

Committer: Andrew Kelley

## Message

````
translate-c: add wide string literal support

Adds support for wide, UTF-16, and UTF-32 string literals. If used to initialize
an incomplete array, the same logic as narrow strings is used. Otherwise they
are translated as global "anonymous" arrays of the relevant underlying char type.
A dot is used in the name to ensure the generated names do not conflict with any
other names in the translated program.

For example:

```c
void my_fn() {
    const uint32_t *foo = U"foo";
}
```

becomes:
```zig
const @"zig.UTF32_string_2" = [4]c_uint{
    '\u{66}',
    '\u{6f}',
    '\u{6f}',
    0,
};
pub export fn my_fn() void {
    var foo: [*c]const u32 = &@"zig.UTF32_string_2";
}
```

````

## Parents

- [79730e6f5cdf13b2514781881e69c557fd52eaea](https://git.cafe/gitcafe/zig/commit/79730e6f5cdf13b2514781881e69c557fd52eaea?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/1ed8c54cd349497adb264b0502783a6422e4f2d1?format=markdown)
