72 Commits

Author SHA1 Message Date
Cameron Cawley c6ae30e7ea COMMON: Support creating strings from a repeated single character 2025-06-20 00:07:23 +02:00
Cameron Cawley b78d519ed3 COMMON: Make String::assignAppend public and extend it 2025-06-20 00:07:23 +02:00
Cameron Cawley e31b6ea8a7 COMMON: Unified implementation of constructing strings with single characters 2024-11-29 01:16:55 +02:00
D G Turner 72db454796 COMMON: Forbid itoa() and uitoa() Usage
These functions are often present, but not reliably portable.

They are not defined in ANSI C and while they are likely present in
the stdlib.h, the exact behaviour especialy for invalid inputs can
vary.

Replacing usage of these functions in engines with Common::String::format()
is recommended.
2024-03-09 21:38:18 +02:00
Cameron Cawley a8183c7734 COMMON: Insert all characters in one go with String::insertString() 2024-01-08 23:39:22 +01:00
Cameron Cawley dce0f057ec COMMON: Optimize U32String::vformat a bit by appending chars instead of inserting them 2024-01-08 23:39:22 +01:00
Cameron Cawley 6c06ae6125 COMMON: Simplify = and += operators for U32String and DBCSString 2024-01-08 23:39:22 +01:00
Cameron Cawley 4abc229268 COMMON: Unify implementations of String::replace() 2024-01-08 23:39:22 +01:00
Cameron Cawley 15a96f8c33 COMMON: Modify U32String::itoa() to use value_type instead of char 2024-01-08 23:39:22 +01:00
hax0kartik cc1e8600e2 COMMON: Add replace() methods for U32String 2023-02-27 22:01:13 +01:00
Cameron Cawley 3441c7230d COMMON: Fix handling escaped percents in Common::U32String::format 2022-11-20 14:23:30 +01:00
Cameron Cawley 29024cded7 COMMON: Fix handling negative numbers in Common::U32String::format 2022-11-20 14:23:30 +01:00
elasota cdedda7fa8 COMMON: Add move semantic assign and construct to strings 2022-09-28 17:09:34 +02:00
elasota 55d31b0260 COMMON: Pass U32String format params by reference and fix warnings about passing a non-trivial class to va_start. 2022-09-24 10:16:24 +02:00
Le Philousophe 092cb26b50 Revert "COMMON: Avoid passing U32String full object as parameter"
This reverts commit 64675dbba6.
It fails on MSVC with error:
C2338    static_assert failed: 'va_start argument must not have reference type and must not be parenthesized'
2022-09-18 22:46:54 +02:00
Le Philousophe 64675dbba6 COMMON: Avoid passing U32String full object as parameter
Use a const reference instead
2022-09-18 16:15:56 +02:00
Eugene Sandulenko abea37c9bb ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
djsrv b2988ce682 COMMON: Add constructor to make U32String from a character 2021-07-15 16:31:47 -04:00
djsrv e6a5380989 COMMON: Add U32String version of toPrintable
This only escapes ASCII control characters, not characters wih
codepoints > 127.
2021-07-12 15:41:21 -04:00
Vladimir Serbinenko 68a9136e4d COMMON: Rewrite Encoder and drop dependency on iconv (#2586)
Different platforms have different levels of support of encodings and
often have slight variations. We already have tables for most encoding
with only CJK missing. Full transcoding inclusion allows us to get reliable
encoding results independently of platform. The biggest con is the need for
external tables encoding.dat.

It removes a duplicate table for korean in graphics/korfont.cpp
2020-11-15 16:20:35 +01:00
Thierry Crozat efa9a0f250 COMMON: Add conversion operator from UnicodeBiDiText to U32String
This replaces the U32String constructor that takes a UnicodeBiDiText
and serves the same purpose, but avoids making a copy.
2020-11-07 18:10:44 +00:00
Thierry Crozat e5bfe63087 COMMON: Merge the String and U32String destructors
The call to decRefCount has been moved to the destructor
of the base class BaseString.

Note that BaseString only exists for the purpose of being able
to reuse code for our String and U32String implementations. As
such it is not meant to be used polymorphically and its
destructor does not need to be virtual (with the overhead that
this generates). And to ensure that it is not used in a
polymorphic way, the destructor is declared protected.
2020-11-05 23:52:19 +00:00
Vladimir Serbinenko 3fc822e55c COMMON: introduce substr for U32String (#2585)
It's safer than direct array manipulation. Replace current uses
of subsetting with substr.
2020-11-01 22:53:03 +01:00
Vladimir Serbinenko 93ee9d0896 COMMON: Fix operator+ declaration in U32String 2020-10-31 23:56:40 +01:00
Thierry Crozat d2251bde1c COMMON: Fix additional compilation errors in U32String 2020-10-31 21:32:36 +00:00
Thierry Crozat 0b93a68a0d COMMON: Attempt to fix compilation for some compilers 2020-10-31 16:56:50 +00:00
Vladimir Serbinenko 29cfa7bb0f COMMON: Merge code for str.cpp and ustr.cpp
Most of the code in str.cpp and ustr.cpp is actually the same. Do some
template magic to merge them.
2020-10-31 14:05:30 +01:00
Vladimir Menshakov 0a4154318c COMMON: implement %c formatter (used in hardware-input.cpp)
Fix invalid descriptor name for half-axis.
Add some tests for U32String::Format.
2020-09-12 11:56:17 +01:00
Thierry Crozat 54f825359f COMMON: Allow using U32String::format with a C string format string 2020-09-08 21:22:04 +01:00
Cameron Cawley 5a6e411bfd COMMON: Fix U32String::itoa when num is 0 2020-09-06 13:20:05 +01:00
Thierry Crozat 9ab48df4b6 COMMON: Fix comparaison operators for U32String
They were supposed to compare two U32String, but due to a copy/paste
error they were comparing a U32String with a String. It compiled
because there is a String constructor that takes a U32String (and
converts it to UTF-8), but it was probably not quite working as
expected for non-ASCII characters.
2020-09-02 21:01:15 +01:00
Vladimir Menshakov 8ddcbf8120 COMMON: Fix warnings about different signedness (uint32/char comparison), remove unused var
Add tests for both str/ustr comparison operators.
2020-09-02 20:35:43 +01:00
Thierry Crozat 9fcc83c09d COMMON: Add comparison operators to U32String
Those operators just compare the numerical value of each character
one by one. This is not idea, but this is better than nothing.
2020-09-02 12:08:49 +02:00
Thierry Crozat 1b67a0f069 COMMON: Fix assingning a String to a U32String
When assigning a String or char * to an existing U32String, the code
assumed that the current _str pointed to the internal storage. But
that is not the case if the U32String contains a string longer
than the internal storage capacity prior to the assignment, and
this led to various memory issues (and usually a crash down the
line).
2020-09-01 00:12:03 +01:00
aryanrawlani28 fe561ecdee COMMON: U32: Fix incorrect usage of %i
- %i & %d work in the same manner.
2020-08-30 20:03:26 +01:00
aryanrawlani28 ca54adca47 COMMON: U32: Fix different types of string pointers for u32
- Previous changes broke compilation for AmigaOS.
2020-08-30 18:56:12 +01:00
aryanrawlani28 140eddf90a GUI: U32: Allow vformat to take in a pointer to a translated string
- Fix signed/unsigned comparision in U32String::contains(U32String)
2020-08-30 14:43:41 +02:00
aryanrawlani28 1d85a3d8e1 GUI: U32: Fix incorrect type for single char in U32::vformat 2020-08-30 14:43:41 +02:00
aryanrawlani28 2ca907b4a2 GUI: U32: Use game-list filters with u32
- Add a contains utility function to ustr
- setFilter uses U32String and U32Tokenizers
- Make consequent changes in launcher to allow sending u32strings
2020-08-30 14:43:41 +02:00
aryanrawlani28 12e4f871a3 GUI: U32: Improve u32 in all engine subsystems
- Common: add wordWrap function to ustr.cpp
- Bladerunner: Explicitly state we have a U32String in subs (same as Subtitles::loadOuttakeSubsText)
- Don't use translations for engine specific "put strings", because they might not support.
- SCI: Use const references for showScummVMDialog
- SCUMM:
-- Don't use translation in md5 warning. left comments with the translated version.
-- Remove some redundant headers in help.cpp
-- Don't use translation in handleSaveload when printing to console
-- Also, display success transaction correctly via u32::format
- TESTBED: Use fake constructor when setting label of button
- SKY: Correctly use translation when using SaveStateDescription
- ULTIMA: Don't use translations when display_string
- ENGINES:
-- GenerateUnknownGameReport correctly, with proper translations.
-- There was an error, where a function had been declared twice, in a header file. Correct this.
2020-08-30 14:43:41 +02:00
aryanrawlani28 68d01321d6 GUI: U32: Downscale changes of U32, fix review issues
This commit addresses a range of changes, within scummvm subproject.

- Audio files, like mididrv, remove U32String based name and identifier, because ASCII only.
- mididrv.cpp had some wrong format for warning messages, fix those
- Message dialogs were modified to use default arguments more often, but reverting back to the orignal to minimize changes.
- SetTooltip has a fake constructor that takes in a string, and use it.
- U32Format had some break statements missing, add those.
- RemapWidget: Use fake constructor for setLabel and setTooltip, to make minimal changes
- SDL: setting text in clipboard no longer uses SDL_iconv_string
- TTS: Override base class "say" with strings, so tts->say can be used with normal strings too.
- About dialog: fix incorrect code for u32string variables
- Fix some extra brackets
- Some buttons were incorrectly removed from using translated labels, revert those
- Message Dialog: Pass default and alt buttons as const references
- Saveload Dialog: Use translations in missing places, use const-references. Also, use translations in a correct manner.
- Use const references for tooltip in GraphicsWidget, EditTextWidget, error.cpp
- DomainEditTextWidget: Use U32String for text
2020-08-30 14:43:41 +02:00
aryanrawlani28 185fb72783 GUI: U32: Improve U32 code
- Revert accidentally put translations in mt32.cpp
- Use U32::format in some places earlier missed
- Add %u and %i for u32::format
- Add support for GUIErrorMsgFormat to use u32::format internally
- Use the above whereever needed
- Improve linux tts by removing redundant code
- Some places I had changed nullptr -> "". Revert this
2020-08-30 14:43:41 +02:00
aryanrawlani28 a9a816e7fe GUI: U32: Improve U32String::format
- Keep adding chars and strings to output instead of deleting and inserting at specific pos
- Use const_iterators for input
2020-08-30 14:43:41 +02:00
aryanrawlani28 c142360bf4 GUI: U32: Add minimal implementation for itoa (base 10) 2020-08-30 14:43:41 +02:00
aryanrawlani28 a9bfe35216 GUI: U32: More issue fixes and general improvements
- Use the fake constructor for message dialog less often
- solve errors regarding comparision between string and u32string in midi
- solve errors in testbed/speech related to ttsMan->say
- fix unsigned comparision warning in tab.cpp
- fix issue with static strings and translations in sdl-graphics
2020-08-30 14:43:41 +02:00
aryanrawlani28 da380a9002 GUI: U32: Fix issues with ustr formatting
- Fix one off error with 'pos'
- Fix last line not being inserted in osdMessage when display
2020-08-30 14:43:41 +02:00
aryanrawlani28 1ca1712b4d GUI: U32: Fix problems with u32strings formatting
- Improve U32's format helper
- Add insertString helper to u32
2020-08-30 14:43:41 +02:00
aryanrawlani28 f800ca4ada GUI: U32: Convert majority of code to use U32
This commit also includes some additional major changes.

- Return U32String from TransMan getTranslation()
- Change tooltips to be U32Strings
- Remove temporary code of convertToU32String
- U32 Support various dialogs (Browser, FileBrowser, Messages, Chooser, etc)
- U32 for music plugins
- U32 for OSD messages
- Add some helper functions to ustr.cpp
- Change default tooltips from nullptr & 0 -> ""
- Some runtime exceptions may occur when changing languages due to incorrect String::Format
2020-08-30 14:43:41 +02:00
aryanrawlani28 4ea2b46ce8 GUI: U32: Add asuint64 helper to ustr 2020-08-30 14:43:41 +02:00
BLooperZ ec83715b43 COMMON: add UnicodeBiDiText wrapper 2020-05-12 14:36:09 +02:00