Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions OVP/D3D9Client/D3D9Pad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ static std::string UTF8ToCP1252(const char *utf8, int ulen)
{
// Convert UTF-8 to Windows-1252
// Get the required length to convert from UTF-8 to UTF-16
int wlen = MultiByteToWideChar(CP_UTF8, 0, utf8, ulen, nullptr, 0);
// Use MB_ERR_INVALID_CHARS to have the call fail if the string
// contains invalid characters. In that case we assume it's
// a legacy plugin providing a Windows-1252 string instead of UTF-8
int wlen = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, utf8, ulen, nullptr, 0);

// In case of a problem, return the original string
// to help with backward compatibility
// Return the original string and hope it was already using Windows-1252
if (wlen == 0) {
return std::string(utf8);
}
Expand Down
6 changes: 6 additions & 0 deletions Orbitersdk/include/DrawAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,8 @@ class OAPIFUNC Sketchpad
* \return width of the string, drawn in the currently selected font [pixel]
* \default None, returns 0.
* \sa SetFont
* \note If the user provides a Windows-1252 encoded string, an heuristic is used
* that *may* provide the expected result
*/
virtual DWORD GetTextWidth (const char *str, int len = 0) { assert(false); return 0; }

Expand Down Expand Up @@ -1181,6 +1183,8 @@ class OAPIFUNC Sketchpad
* \param len string length for output
* \return \e true on success, \e false on failure.
* \default None, returns false.
* \note If the user provides a Windows-1252 encoded string, an heuristic is used
* that *may* provide the expected result
*/
virtual bool Text (int x, int y, const char *str, int len) { assert(false); return false; }

Expand All @@ -1199,6 +1203,8 @@ class OAPIFUNC Sketchpad
* be applied as required to fit the text in the box.
* \note The bottom edge (y2) should probably be ignored, so text isn't
* truncated if it doesn't fit the box.
* \note If the user provides a Windows-1252 encoded string, an heuristic is used
* that *may* provide the expected result
*/
virtual bool TextBox (int x1, int y1, int x2, int y2, const char *str, int len);

Expand Down
Loading