#undef _IRR_COMPILE_WITH_LIBPNG_\r
#endif\r
\r
-//! Define _IRR_D3D_NO_SHADER_DEBUGGING to disable shader debugging in D3D9\r
-/** If _IRR_D3D_NO_SHADER_DEBUGGING is undefined in IrrCompileConfig.h,\r
-it is possible to debug all D3D9 shaders in VisualStudio. All shaders\r
-(which have been generated in memory or read from archives for example) will be emitted\r
-into a temporary file at runtime for this purpose. To debug your shaders, choose\r
-Debug->Direct3D->StartWithDirect3DDebugging in Visual Studio, and for every shader a\r
-file named 'irr_dbg_shader_%%.vsh' or 'irr_dbg_shader_%%.psh' will be created. Drag'n'drop\r
-the file you want to debug into visual studio. That's it. You can now set breakpoints and\r
-watch registers, variables etc. This works with ASM, HLSL, and both with pixel and vertex shaders.\r
-Note that the engine will run in D3D REF for this, which is a lot slower than HAL. */\r
-#define _IRR_D3D_NO_SHADER_DEBUGGING\r
-#ifdef NO_IRR_D3D_NO_SHADER_DEBUGGING\r
-#undef _IRR_D3D_NO_SHADER_DEBUGGING\r
-#endif\r
-\r
-//! Define _IRR_D3D_USE_LEGACY_HLSL_COMPILER to enable the old HLSL compiler in recent DX SDKs\r
-/** This enables support for ps_1_x shaders for recent DX SDKs. Otherwise, support\r
-for this shader model is not available anymore in SDKs after Oct2006. You need to\r
-distribute the OCT2006_d3dx9_31_x86.cab or OCT2006_d3dx9_31_x64.cab though, in order\r
-to provide the user with the proper DLL. That's why it's disabled by default. */\r
-//#define _IRR_D3D_USE_LEGACY_HLSL_COMPILER\r
-#ifdef NO_IRR_D3D_USE_LEGACY_HLSL_COMPILER\r
-#undef _IRR_D3D_USE_LEGACY_HLSL_COMPILER\r
-#endif\r
-\r
-//! Define _IRR_USE_NVIDIA_PERFHUD_ to opt-in to using the nVidia PerHUD tool\r
-/** Enable, by opting-in, to use the nVidia PerfHUD performance analysis driver\r
-tool <http://developer.nvidia.com/object/nvperfhud_home.html>. */\r
-#undef _IRR_USE_NVIDIA_PERFHUD_\r
-\r
-//! Define one of the three setting for Burning's Video Software Rasterizer\r
-/** So if we were marketing guys we could say Irrlicht has 4 Software-Rasterizers.\r
- In a Nutshell:\r
- All Burnings Rasterizers use 32 Bit Backbuffer, 32Bit Texture & 32 Bit Z or WBuffer,\r
- 16 Bit/32 Bit can be adjusted on a global flag.\r
-\r
- BURNINGVIDEO_RENDERER_BEAUTIFUL\r
- 32 Bit + Vertexcolor + Lighting + Per Pixel Perspective Correct + SubPixel/SubTexel Correct +\r
- Bilinear Texturefiltering + WBuffer\r
-\r
- BURNINGVIDEO_RENDERER_FAST\r
- 32 Bit + Per Pixel Perspective Correct + SubPixel/SubTexel Correct + WBuffer +\r
- Bilinear Dithering TextureFiltering + WBuffer\r
-\r
- BURNINGVIDEO_RENDERER_ULTRA_FAST\r
- 16Bit + SubPixel/SubTexel Correct + ZBuffer\r
-*/\r
-\r
//! Uncomment the following line if you want to ignore the deprecated warnings\r
//#define IGNORE_DEPRECATED_WARNING\r
\r
+++ /dev/null
-// Copyright (C) 2002-2012 Nikolaus Gebhardt\r
-// This file is part of the "Irrlicht Engine".\r
-// For conditions of distribution and use, see copyright notice in irrlicht.h\r
-\r
-// replaced by template\r
-#include "CMeshBuffer.h"\r
-\r
+++ /dev/null
-// Copyright (C) 2002-2012 Nikolaus Gebhardt\r
-// This file is part of the "Irrlicht Engine".\r
-// For conditions of distribution and use, see copyright notice in irrlicht.h\r
-\r
-// replaced by template\r
-#include "CMeshBuffer.h"\r
-\r
+++ /dev/null
-// Copyright (C) 2002-2012 Nikolaus Gebhardt\r
-// This file is part of the "Irrlicht Engine".\r
-// For conditions of distribution and use, see copyright notice in irrlicht.h\r
-\r
-#ifndef __S_PARTICLE_H_INCLUDED__\r
-#define __S_PARTICLE_H_INCLUDED__\r
-\r
-#include "vector3d.h"\r
-#include "dimension2d.h"\r
-#include "SColor.h"\r
-\r
-namespace irr\r
-{\r
-namespace scene\r
-{\r
- //! Struct for holding particle data\r
- struct SParticle\r
- {\r
- //! Position of the particle\r
- core::vector3df pos;\r
-\r
- //! Direction and speed of the particle\r
- core::vector3df vector;\r
-\r
- //! Start life time of the particle\r
- u32 startTime;\r
-\r
- //! End life time of the particle\r
- u32 endTime;\r
-\r
- //! Current color of the particle\r
- video::SColor color;\r
-\r
- //! Original color of the particle.\r
- /** That's the color of the particle it had when it was emitted. */\r
- video::SColor startColor;\r
-\r
- //! Original direction and speed of the particle.\r
- /** The direction and speed the particle had when it was emitted. */\r
- core::vector3df startVector;\r
-\r
- //! Scale of the particle.\r
- /** The current scale of the particle. */\r
- core::dimension2df size;\r
-\r
- //! Original scale of the particle.\r
- /** The scale of the particle when it was emitted. */\r
- core::dimension2df startSize;\r
- };\r
-\r
-\r
-} // end namespace scene\r
-} // end namespace irr\r
-\r
-#endif\r
-\r
};\r
\r
\r
-/*\r
-//! vertex index used by the Irrlicht engine.\r
-template <class T>\r
-struct SSpecificVertexIndex\r
-{\r
- T Index;\r
-\r
- //! default constructor\r
- SSpecificVertexIndex() {}\r
-\r
- //! constructor\r
- SSpecificVertexIndex(u32 _index) :Index(_index) {}\r
-\r
- bool operator==(const SSpecificVertexIndex& other) const\r
- {\r
- return (Index == other.Index);\r
- }\r
-\r
- bool operator!=(const SSpecificVertexIndex& other) const\r
- {\r
- return (Index != other.Index);\r
- }\r
-\r
- bool operator<(const SSpecificVertexIndex& other) const\r
- {\r
- return (Index < other.Index);\r
- }\r
-\r
- SSpecificVertexIndex operator+(const u32& other) const\r
- {\r
- return SSpecificVertexIndex(Index + other);\r
- }\r
-\r
- operator const u32() const\r
- {\r
- return (const u32)Index;\r
- }\r
-\r
- E_INDEX_TYPE getType() const\r
- {\r
- if (sizeof(T)==sizeof(u16))\r
- return video::EIT_16BIT;\r
- return video::EIT_32BIT;\r
- }\r
-\r
-};\r
-\r
-//typedef SSpecificVertexIndex<u16> SVertexIndex;\r
-\r
-typedef u32 SVertexIndex;\r
-*/\r
-\r
-\r
} // end namespace video\r
} // end namespace irr\r
\r
**/\r
const c8* const ALLOW_ZWRITE_ON_TRANSPARENT = "Allow_ZWrite_On_Transparent";\r
\r
- //! Deprecated, use IMeshLoader::getMeshTextureLoader()->setTexturePath instead.\r
- /** Was used for changing the texture path of the built-in csm loader like this:\r
- \code\r
- SceneManager->getParameters()->setAttribute(scene::CSM_TEXTURE_PATH, "path/to/your/textures");\r
- \endcode\r
- **/\r
- const c8* const CSM_TEXTURE_PATH = "CSM_TexturePath";\r
-\r
- //! Deprecated, use IMeshLoader::getMeshTextureLoader()->setTexturePath instead.\r
- /** Was used for changing the texture path of the built-in lmts loader like this:\r
- \code\r
- SceneManager->getParameters()->setAttribute(scene::LMTS_TEXTURE_PATH, "path/to/your/textures");\r
- \endcode\r
- **/\r
- const c8* const LMTS_TEXTURE_PATH = "LMTS_TexturePath";\r
-\r
- //! Deprecated, use IMeshLoader::getMeshTextureLoader()->setTexturePath instead.\r
- /** Was used for changing the texture path of the built-in MY3D loader like this:\r
- \code\r
- SceneManager->getParameters()->setAttribute(scene::MY3D_TEXTURE_PATH, "path/to/your/textures");\r
- \endcode\r
- **/\r
- const c8* const MY3D_TEXTURE_PATH = "MY3D_TexturePath";\r
-\r
- //! Name of the parameter specifying the COLLADA mesh loading mode\r
- /**\r
- Specifies if the COLLADA loader should create instances of the models, lights and\r
- cameras when loading COLLADA meshes. By default, this is set to false. If this is\r
- set to true, the ISceneManager::getMesh() method will only return a pointer to a\r
- dummy mesh and create instances of all meshes and lights and cameras in the collada\r
- file by itself. Example:\r
- \code\r
- SceneManager->getParameters()->setAttribute(scene::COLLADA_CREATE_SCENE_INSTANCES, true);\r
- \endcode\r
- */\r
- const c8* const COLLADA_CREATE_SCENE_INSTANCES = "COLLADA_CreateSceneInstances";\r
-\r
- //! Deprecated, use IMeshLoader::getMeshTextureLoader()->setTexturePath instead.\r
- /** This path is prefixed to the file names defined in the Deled file when loading\r
- textures. This allows to alter the paths for a specific project setting.\r
- Use it like this:\r
- \code\r
- SceneManager->getStringParameters()->setAttribute(scene::DMF_TEXTURE_PATH, "path/to/your/textures");\r
- \endcode\r
- **/\r
- const c8* const DMF_TEXTURE_PATH = "DMF_TexturePath";\r
-\r
- //! Name of the parameter for preserving DMF textures dir structure with built-in DMF loader.\r
- /** If this parameter is set to true, the texture directory defined in the Deled file\r
- is ignored, and only the texture name is used to find the proper file. Otherwise, the\r
- texture path is also used, which allows to use a nicer media layout.\r
- Use it like this:\r
- \code\r
- //this way you won't use this setting (default)\r
- SceneManager->getParameters()->setAttribute(scene::DMF_IGNORE_MATERIALS_DIRS, false);\r
- \endcode\r
- \code\r
- //this way you'll use this setting\r
- SceneManager->getParameters()->setAttribute(scene::DMF_IGNORE_MATERIALS_DIRS, true);\r
- \endcode\r
- **/\r
- const c8* const DMF_IGNORE_MATERIALS_DIRS = "DMF_IgnoreMaterialsDir";\r
-\r
- //! Name of the parameter for setting reference value of alpha in transparent materials.\r
- /** Use it like this:\r
- \code\r
- //this way you'll set alpha ref to 0.1\r
- SceneManager->getParameters()->setAttribute(scene::DMF_ALPHA_CHANNEL_REF, 0.1);\r
- \endcode\r
- **/\r
- const c8* const DMF_ALPHA_CHANNEL_REF = "DMF_AlphaRef";\r
-\r
- //! Name of the parameter for choose to flip or not tga files.\r
- /** Use it like this:\r
- \code\r
- //this way you'll choose to flip alpha textures\r
- SceneManager->getParameters()->setAttribute(scene::DMF_FLIP_ALPHA_TEXTURES, true);\r
- \endcode\r
- **/\r
- const c8* const DMF_FLIP_ALPHA_TEXTURES = "DMF_FlipAlpha";\r
-\r
-\r
- //! Deprecated, use IMeshLoader::getMeshTextureLoader()->setTexturePath instead.\r
- /** Was used for changing the texture path of the built-in obj loader like this:\r
- \code\r
- SceneManager->getParameters()->setAttribute(scene::OBJ_TEXTURE_PATH, "path/to/your/textures");\r
- \endcode\r
- **/\r
- const c8* const OBJ_TEXTURE_PATH = "OBJ_TexturePath";\r
-\r
//! Flag to avoid loading group structures in .obj files\r
/** Use it like this:\r
\code\r
**/\r
const c8* const B3D_LOADER_IGNORE_MIPMAP_FLAG = "B3D_IgnoreMipmapFlag";\r
\r
- //! Deprecated, use IMeshLoader::getMeshTextureLoader()->setTexturePath instead.\r
- /** Was used for changing the texture path of the built-in b3d loader like this:\r
- \code\r
- SceneManager->getParameters()->setAttribute(scene::B3D_TEXTURE_PATH, "path/to/your/textures");\r
- \endcode\r
- **/\r
- const c8* const B3D_TEXTURE_PATH = "B3D_TexturePath";\r
-\r
- //! Flag set as parameter when the scene manager is used as editor\r
- /** In this way special animators like deletion animators can be stopped from\r
- deleting scene nodes for example */\r
- const c8* const IRR_SCENE_MANAGER_IS_EDITOR = "IRR_Editor";\r
-\r
//! Name of the parameter for setting the length of debug normals.\r
/** Use it like this:\r
\code\r
\r
\r
//! some standard function ( to remove dependencies )\r
-inline s32 isdigit(s32 c) { return c >= '0' && c <= '9'; }\r
-inline s32 isspace(s32 c) { return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v'; }\r
-inline s32 isupper(s32 c) { return c >= 'A' && c <= 'Z'; }\r
+inline bool isdigit(s32 c) { return c >= '0' && c <= '9'; }\r
+inline bool isspace(s32 c) { return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v'; }\r
+inline bool isupper(s32 c) { return c >= 'A' && c <= 'Z'; }\r
\r
\r
} // end namespace core\r
{\r
namespace core\r
{\r
- //! Selection of characters which count as decimal point in fast_atof\r
- //! By default Irrlicht considers "." as the decimal point in numbers.\r
- //! But sometimes you might run into situations where floats were written in \r
- //! a local format with another decimal point like ",".\r
- //! Best solution is usually to fix those cases by converting the input.\r
- //! But if you don't have that choice you can set this to ".,".\r
- //! WARNING: This is not thread-safe, so don't change while there's a chance \r
- //! of another thread using fast_atof functions at the same time.\r
- // TODO: This should probably also be used in irr::core::string, but\r
- // the float-to-string code used there has to be rewritten first.\r
- IRRLICHT_API extern irr::core::stringc LOCALE_DECIMAL_POINTS;\r
\r
#define IRR_ATOF_TABLE_SIZE 17\r
// we write [IRR_ATOF_TABLE_SIZE] here instead of [] to work around a swig bug\r
\r
f32 value = strtof10(in, &in);\r
\r
- if ( LOCALE_DECIMAL_POINTS.findFirst(*in) >= 0 )\r
+ if ( *in == '.' )\r
{\r
const char* afterDecimal = ++in;\r
const f32 decimal = strtof10(in, &afterDecimal);\r
class string;\r
static size_t multibyteToWString(string<wchar_t>& destination, const char* source, u32 sourceSize);\r
static size_t wStringToMultibyte(string<c8>& destination, const wchar_t* source, u32 sourceSize);\r
-inline s32 isdigit(s32 c);\r
-\r
-enum eLocaleID\r
-{\r
- IRR_LOCALE_ANSI = 0,\r
- IRR_LOCALE_GERMAN = 1\r
-};\r
-\r
-static eLocaleID locale_current = IRR_LOCALE_ANSI;\r
-static inline void locale_set ( eLocaleID id )\r
-{\r
- locale_current = id;\r
-}\r
+inline bool isdigit(s32 c);\r
\r
//! Returns a character converted to lower case\r
static inline u32 locale_lower ( u32 x )\r
{\r
- switch ( locale_current )\r
- {\r
- case IRR_LOCALE_GERMAN:\r
- case IRR_LOCALE_ANSI:\r
- break;\r
- }\r
// ansi\r
return x >= 'A' && x <= 'Z' ? x + 0x20 : x;\r
}\r
//! Returns a character converted to upper case\r
static inline u32 locale_upper ( u32 x )\r
{\r
- switch ( locale_current )\r
- {\r
- case IRR_LOCALE_GERMAN:\r
- case IRR_LOCALE_ANSI:\r
- break;\r
- }\r
-\r
// ansi\r
return x >= 'a' && x <= 'z' ? x + ( 'A' - 'a' ) : x;\r
}\r
\r
-//! Convert this utf-8-encoded string to the platform's wchar.\r
-/** The resulting string is always NULL-terminated and well-formed.\r
-\param len The size of the output buffer in bytes.\r
-*/\r
-IRRLICHT_API void utf8ToWchar(const char *in, wchar_t *out, const u64 len);\r
-\r
-//! Convert this wchar string to utf-8.\r
-/** The resulting string is always NULL-terminated and well-formed.\r
-\param len The size of the output buffer in bytes.\r
-*/\r
-IRRLICHT_API void wcharToUtf8(const wchar_t *in, char *out, const u64 len);\r
-\r
\r
template <typename T, typename TAlloc>\r
class string\r
#include "SMaterial.h"\r
#include "SMesh.h"\r
#include "SMeshBuffer.h"\r
-#include "SMeshBufferLightMap.h"\r
-#include "SMeshBufferTangents.h"\r
-#include "SParticle.h"\r
#include "SSharedMeshBuffer.h"\r
#include "SSkinMeshBuffer.h"\r
#include "SVertexIndex.h"\r
os.cpp
leakHunter.cpp
CProfiler.cpp
- utf8.cpp
)
if(ANDROID)
\r
#include "CSceneCollisionManager.h"\r
\r
-#include <locale.h>\r
-\r
namespace irr\r
{\r
namespace scene\r
namespace core\r
{\r
const matrix4 IdentityMatrix(matrix4::EM4CONST_IDENTITY);\r
- irr::core::stringc LOCALE_DECIMAL_POINTS(".");\r
}\r
\r
namespace video\r
+++ /dev/null
-// Copyright (C) 2014 Lauri Kasanen
-// This file is part of the "Irrlicht Engine". The UTF-8 functions are from physfs,
-// under the zlib license, reproduced below.
-
-#include "irrTypes.h"
-#include "irrString.h"
-
-namespace irr
-{
-namespace core
-{
-
-/*
- Copyright (c) 2001-2011 Ryan C. Gordon and others.
-
- This software is provided 'as-is', without any express or implied warranty.
- In no event will the authors be held liable for any damages arising from
- the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software in a
- product, an acknowledgment in the product documentation would be
- appreciated but is not required.
-
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
-
- 3. This notice may not be removed or altered from any source distribution.
-
- Ryan C. Gordon <icculus@icculus.org>
-*/
-
-/*
- * From rfc3629, the UTF-8 spec:
- * http://www.ietf.org/rfc/rfc3629.txt
- *
- * Char. number range | UTF-8 octet sequence
- * (hexadecimal) | (binary)
- * --------------------+---------------------------------------------
- * 0000 0000-0000 007F | 0xxxxxxx
- * 0000 0080-0000 07FF | 110xxxxx 10xxxxxx
- * 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
- * 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
- */
-
-
-/*
- * This may not be the best value, but it's one that isn't represented
- * in Unicode (0x10FFFF is the largest codepoint value). We return this
- * value from utf8codepoint() if there's bogus bits in the
- * stream. utf8codepoint() will turn this value into something
- * reasonable (like a question mark), for text that wants to try to recover,
- * whereas utf8valid() will use the value to determine if a string has bad
- * bits.
- */
-#define UNICODE_BOGUS_CHAR_VALUE 0xFFFFFFFF
-
-/*
- * This is the codepoint we currently return when there was bogus bits in a
- * UTF-8 string. May not fly in Asian locales?
- */
-#define UNICODE_BOGUS_CHAR_CODEPOINT '?'
-
-static u32 utf8codepoint(const char **_str)
-{
- const char *str = *_str;
- u32 retval = 0;
- u32 octet = (u32) ((u8) *str);
- u32 octet2, octet3, octet4;
-
- if (octet == 0) /* null terminator, end of string. */
- return 0;
-
- else if (octet < 128) /* one octet char: 0 to 127 */
- {
- (*_str)++; /* skip to next possible start of codepoint. */
- return(octet);
- } /* else if */
-
- else if ((octet > 127) && (octet < 192)) /* bad (starts with 10xxxxxx). */
- {
- /*
- * Apparently each of these is supposed to be flagged as a bogus
- * char, instead of just resyncing to the next valid codepoint.
- */
- (*_str)++; /* skip to next possible start of codepoint. */
- return UNICODE_BOGUS_CHAR_VALUE;
- } /* else if */
-
- else if (octet < 224) /* two octets */
- {
- octet -= (128+64);
- octet2 = (u32) ((u8) *(++str));
- if ((octet2 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
- return UNICODE_BOGUS_CHAR_VALUE;
-
- *_str += 2; /* skip to next possible start of codepoint. */
- retval = ((octet << 6) | (octet2 - 128));
- if ((retval >= 0x80) && (retval <= 0x7FF))
- return retval;
- } /* else if */
-
- else if (octet < 240) /* three octets */
- {
- octet -= (128+64+32);
- octet2 = (u32) ((u8) *(++str));
- if ((octet2 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
- return UNICODE_BOGUS_CHAR_VALUE;
-
- octet3 = (u32) ((u8) *(++str));
- if ((octet3 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
- return UNICODE_BOGUS_CHAR_VALUE;
-
- *_str += 3; /* skip to next possible start of codepoint. */
- retval = ( ((octet << 12)) | ((octet2-128) << 6) | ((octet3-128)) );
-
- /* There are seven "UTF-16 surrogates" that are illegal in UTF-8. */
- switch (retval)
- {
- case 0xD800:
- case 0xDB7F:
- case 0xDB80:
- case 0xDBFF:
- case 0xDC00:
- case 0xDF80:
- case 0xDFFF:
- return UNICODE_BOGUS_CHAR_VALUE;
- } /* switch */
-
- /* 0xFFFE and 0xFFFF are illegal, too, so we check them at the edge. */
- if ((retval >= 0x800) && (retval <= 0xFFFD))
- return retval;
- } /* else if */
-
- else if (octet < 248) /* four octets */
- {
- octet -= (128+64+32+16);
- octet2 = (u32) ((u8) *(++str));
- if ((octet2 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
- return UNICODE_BOGUS_CHAR_VALUE;
-
- octet3 = (u32) ((u8) *(++str));
- if ((octet3 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
- return UNICODE_BOGUS_CHAR_VALUE;
-
- octet4 = (u32) ((u8) *(++str));
- if ((octet4 & (128+64)) != 128) /* Format isn't 10xxxxxx? */
- return UNICODE_BOGUS_CHAR_VALUE;
-
- *_str += 4; /* skip to next possible start of codepoint. */
- retval = ( ((octet << 18)) | ((octet2 - 128) << 12) |
- ((octet3 - 128) << 6) | ((octet4 - 128)) );
- if ((retval >= 0x10000) && (retval <= 0x10FFFF))
- return retval;
- } /* else if */
-
- /*
- * Five and six octet sequences became illegal in rfc3629.
- * We throw the codepoint away, but parse them to make sure we move
- * ahead the right number of bytes and don't overflow the buffer.
- */
-
- else if (octet < 252) /* five octets */
- {
- octet = (u32) ((u8) *(++str));
- if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
- return UNICODE_BOGUS_CHAR_VALUE;
-
- octet = (u32) ((u8) *(++str));
- if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
- return UNICODE_BOGUS_CHAR_VALUE;
-
- octet = (u32) ((u8) *(++str));
- if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
- return UNICODE_BOGUS_CHAR_VALUE;
-
- octet = (u32) ((u8) *(++str));
- if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
- return UNICODE_BOGUS_CHAR_VALUE;
-
- *_str += 5; /* skip to next possible start of codepoint. */
- return UNICODE_BOGUS_CHAR_VALUE;
- } /* else if */
-
- else /* six octets */
- {
- octet = (u32) ((u8) *(++str));
- if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
- return UNICODE_BOGUS_CHAR_VALUE;
-
- octet = (u32) ((u8) *(++str));
- if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
- return UNICODE_BOGUS_CHAR_VALUE;
-
- octet = (u32) ((u8) *(++str));
- if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
- return UNICODE_BOGUS_CHAR_VALUE;
-
- octet = (u32) ((u8) *(++str));
- if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
- return UNICODE_BOGUS_CHAR_VALUE;
-
- octet = (u32) ((u8) *(++str));
- if ((octet & (128+64)) != 128) /* Format isn't 10xxxxxx? */
- return UNICODE_BOGUS_CHAR_VALUE;
-
- *_str += 6; /* skip to next possible start of codepoint. */
- return UNICODE_BOGUS_CHAR_VALUE;
- } /* else if */
-
- return UNICODE_BOGUS_CHAR_VALUE;
-} /* utf8codepoint */
-
-
-static void PHYSFS_utf8ToUcs4(const char *src, u32 *dst, u64 len)
-{
- len -= sizeof (u32); /* save room for null char. */
- while (len >= sizeof (u32))
- {
- u32 cp = utf8codepoint(&src);
- if (cp == 0)
- break;
- else if (cp == UNICODE_BOGUS_CHAR_VALUE)
- cp = UNICODE_BOGUS_CHAR_CODEPOINT;
- *(dst++) = cp;
- len -= sizeof (u32);
- } /* while */
-
- *dst = 0;
-} /* PHYSFS_utf8ToUcs4 */
-
-
-static void PHYSFS_utf8ToUcs2(const char *src, u16 *dst, u64 len)
-{
- len -= sizeof (u16); /* save room for null char. */
- while (len >= sizeof (u16))
- {
- u32 cp = utf8codepoint(&src);
- if (cp == 0)
- break;
- else if (cp == UNICODE_BOGUS_CHAR_VALUE)
- cp = UNICODE_BOGUS_CHAR_CODEPOINT;
-
- /* !!! BLUESKY: UTF-16 surrogates? */
- if (cp > 0xFFFF)
- cp = UNICODE_BOGUS_CHAR_CODEPOINT;
-
- *(dst++) = cp;
- len -= sizeof (u16);
- } /* while */
-
- *dst = 0;
-} /* PHYSFS_utf8ToUcs2 */
-
-static void utf8fromcodepoint(u32 cp, char **_dst, u64 *_len)
-{
- char *dst = *_dst;
- u64 len = *_len;
-
- if (len == 0)
- return;
-
- if (cp > 0x10FFFF)
- cp = UNICODE_BOGUS_CHAR_CODEPOINT;
- else if ((cp == 0xFFFE) || (cp == 0xFFFF)) /* illegal values. */
- cp = UNICODE_BOGUS_CHAR_CODEPOINT;
- else
- {
- /* There are seven "UTF-16 surrogates" that are illegal in UTF-8. */
- switch (cp)
- {
- case 0xD800:
- case 0xDB7F:
- case 0xDB80:
- case 0xDBFF:
- case 0xDC00:
- case 0xDF80:
- case 0xDFFF:
- cp = UNICODE_BOGUS_CHAR_CODEPOINT;
- } /* switch */
- } /* else */
-
- /* Do the encoding... */
- if (cp < 0x80)
- {
- *(dst++) = (char) cp;
- len--;
- } /* if */
-
- else if (cp < 0x800)
- {
- if (len < 2)
- len = 0;
- else
- {
- *(dst++) = (char) ((cp >> 6) | 128 | 64);
- *(dst++) = (char) (cp & 0x3F) | 128;
- len -= 2;
- } /* else */
- } /* else if */
-
- else if (cp < 0x10000)
- {
- if (len < 3)
- len = 0;
- else
- {
- *(dst++) = (char) ((cp >> 12) | 128 | 64 | 32);
- *(dst++) = (char) ((cp >> 6) & 0x3F) | 128;
- *(dst++) = (char) (cp & 0x3F) | 128;
- len -= 3;
- } /* else */
- } /* else if */
-
- else
- {
- if (len < 4)
- len = 0;
- else
- {
- *(dst++) = (char) ((cp >> 18) | 128 | 64 | 32 | 16);
- *(dst++) = (char) ((cp >> 12) & 0x3F) | 128;
- *(dst++) = (char) ((cp >> 6) & 0x3F) | 128;
- *(dst++) = (char) (cp & 0x3F) | 128;
- len -= 4;
- } /* else if */
- } /* else */
-
- *_dst = dst;
- *_len = len;
-} /* utf8fromcodepoint */
-
-#define UTF8FROMTYPE(typ, src, dst, len) \
- if (len == 0) return; \
- len--; \
- while (len) \
- { \
- const u32 cp = (u32) ((typ) (*(src++))); \
- if (cp == 0) break; \
- utf8fromcodepoint(cp, &dst, &len); \
- } \
- *dst = '\0'; \
-
-static void PHYSFS_utf8FromUcs4(const u32 *src, char *dst, u64 len)
-{
- UTF8FROMTYPE(u32, src, dst, len);
-} /* PHYSFS_utf8FromUcs4 */
-
-static void PHYSFS_utf8FromUcs2(const u16 *src, char *dst, u64 len)
-{
- UTF8FROMTYPE(u64, src, dst, len);
-} /* PHYSFS_utf8FromUcs4 */
-
-#undef UTF8FROMTYPE
-
-void utf8ToWchar(const char *in, wchar_t *out, const u64 len)
-{
-#ifdef _WIN32
- PHYSFS_utf8ToUcs2(in, (u16 *) out, len);
-#else
- PHYSFS_utf8ToUcs4(in, (u32 *) out, len);
-#endif
-}
-
-void wcharToUtf8(const wchar_t *in, char *out, const u64 len)
-{
-#ifdef _WIN32
- PHYSFS_utf8FromUcs2((const u16 *) in, out, len);
-#else
- PHYSFS_utf8FromUcs4((const u32 *) in, out, len);
-#endif
-}
-
-} // end namespace core
-} // end namespace irr
-