Using the ^ character in strings
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Using the ^ character in strings
I didn't find anything regarding this in the wiki so I'm asking here
For some reason every time I use ^ in a message string it deletes huge parts of the string, for example, if I write this
the unit just says "World", how can I fix this?
For some reason every time I use ^ in a message string it deletes huge parts of the string, for example, if I write this
Code: Select all
[message]
speaker=my_unit
message= _ "Hello ^World"
[/message]
Re: Using the ^ character in strings
Documentation and the explanation about this is on the GettextForWesnothDevelopers page
In 1.15, everything up until the first ^ will be removed, you can include a literal ^ by doing
In 1.14, everything up until the last ^ is removed, there isn't a workaround for that (as far as I can remember).
In 1.15, everything up until the first ^ will be removed, you can include a literal ^ by doing
"prefix^Hello ^World"
.In 1.14, everything up until the last ^ is removed, there isn't a workaround for that (as far as I can remember).
Re: Using the ^ character in strings
There's this simple workaround that seems to work fine in 1.14 too:
Code: Select all
{VARIABLE helper "^"}
[message]
speaker=my_unit
message= _ "Hello $helper|World"
[/message]
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
- Celtic_Minstrel
- Developer
- Posts: 2166
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Using the ^ character in strings
You could also just add an extra ^ at the start of your string.
That should show "Hello ^World". I guess maybe it doesn't work in 1.14 though.
Code: Select all
[message]
speaker=my_unit
message= _ "^Hello ^World"
[/message]
- Elvish_Hunter
- Posts: 1575
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: Using the ^ character in strings
You can always try escaping it just like a HTML entity. The following code seems to work on the 1.15 series:
Code: Select all
[message]
speaker=narrator
caption= _ "Caret test"
message= _ "This should be a literal caret: ^."
[/message]
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
- Celtic_Minstrel
- Developer
- Posts: 2166
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Using the ^ character in strings
Just keep in mind that that's not guaranteed to work everywhere - it'll only work in places that Pango markup is enabled.