chromium/third_party/unrar/src/unicode.cpp

#include "rar.hpp"
#define MBFUNCTIONS

#if defined(_UNIX) && defined(MBFUNCTIONS)

static bool WideToCharMap(const wchar *Src,char *Dest,size_t DestSize,bool &Success);
static void CharToWideMap(const char *Src,wchar *Dest,size_t DestSize,bool &Success);

// In Unix we map high ASCII characters which cannot be converted to Unicode
// to 0xE000 - 0xE0FF private use Unicode area.
static const uint MapAreaStart=;

// Mapped string marker. Initially we used 0xFFFF for this purpose,
// but it causes MSVC2008 swprintf to fail (it treats 0xFFFF as error marker).
// While we could workaround it, it is safer to use another character.
static const uint MappedStringMark=;

#endif

bool WideToChar(const wchar *Src,char *Dest,size_t DestSize)
{}


bool CharToWide(const char *Src,wchar *Dest,size_t DestSize)
{}


bool WideToChar(const std::wstring &Src,std::string &Dest)
{}


bool CharToWide(const std::string &Src,std::wstring &Dest)
{}


#if defined(_UNIX) && defined(MBFUNCTIONS)
// Convert and restore mapped inconvertible Unicode characters. 
// We use it for extended ASCII names in Unix.
bool WideToCharMap(const wchar *Src,char *Dest,size_t DestSize,bool &Success)
{}
#endif


#if defined(_UNIX) && defined(MBFUNCTIONS)
// Convert and map inconvertible Unicode characters.
// We use it for extended ASCII names in Unix.
void CharToWideMap(const char *Src,wchar *Dest,size_t DestSize,bool &Success)
{}
#endif


// SrcSize is source data size in wide characters, not in bytes.
// DestSize is the maximum allowed destination size.
byte* WideToRaw(const wchar *Src,size_t SrcSize,byte *Dest,size_t DestSize)
{}


// Store UTF-16 raw byte stream.
void WideToRaw(const std::wstring &Src,std::vector<byte> &Dest)
{}


wchar* RawToWide(const byte *Src,wchar *Dest,size_t DestSize)
{}


std::wstring RawToWide(const std::vector<byte> &Src)
{}


void WideToUtf(const wchar *Src,char *Dest,size_t DestSize)
{}


void WideToUtf(const std::wstring &Src,std::string &Dest)
{}



size_t WideToUtfSize(const wchar *Src)
{}


bool UtfToWide(const char *Src,wchar *Dest,size_t DestSize)
{}


bool UtfToWide(const char *Src,std::wstring &Dest)
{}


/*
bool UtfToWide(const std::vector<char> &Src,std::wstring &Dest)
{
  bool Success=true;
  Dest.clear();
  for (size_t I=0;I<Src.size() && Src[I]!=0;) // We expect it to always stop at 0.
  {
    uint c=byte(Src[I++]),d;
    if (c<0x80)
      d=c;
    else
      if ((c>>5)==6)
      {
        if (Src.size()-I<1 || (Src[I]&0xc0)!=0x80)
        {
          Success=false;
          break;
        }
        d=((c&0x1f)<<6)|(Src[I]&0x3f);
        I++;
      }
      else
        if ((c>>4)==14)
        {
          if (Src.size()-I<2 || (Src[I]&0xc0)!=0x80 || (Src[I+1]&0xc0)!=0x80)
          {
            Success=false;
            break;
          }
          d=((c&0xf)<<12)|((Src[I]&0x3f)<<6)|(Src[I+1]&0x3f);
          I+=2;
        }
        else
          if ((c>>3)==30)
          {
            if (Src.size()-I<3 || (Src[I]&0xc0)!=0x80 || (Src[I+1]&0xc0)!=0x80 || (Src[I+2]&0xc0)!=0x80)
            {
              Success=false;
              break;
            }
            d=((c&7)<<18)|((Src[I]&0x3f)<<12)|((Src[I+1]&0x3f)<<6)|(Src[I+2]&0x3f);
            I+=3;
          }
          else
          {
            Success=false;
            break;
          }
    if (d>0xffff)
    {
      if (d>0x10ffff) // UTF-8 must end at 0x10ffff according to RFC 3629.
      {
        Success=false;
        continue;
      }
      if (sizeof(Dest[0])==2) // Use the surrogate pair.
      {
        Dest.push_back( ((d-0x10000)>>10)+0xd800 );
        Dest.push_back( (d&0x3ff)+0xdc00 );
      }
      else
        Dest.push_back( d );
    }
    else
      Dest.push_back( d );
  }
  return Success;
}
*/


// For zero terminated strings.
bool IsTextUtf8(const byte *Src)
{}


// Source data can be both with and without UTF-8 BOM.
bool IsTextUtf8(const byte *Src,size_t SrcSize)
{}


int wcsicomp(const wchar *s1,const wchar *s2)
{}


int wcsnicomp(const wchar *s1,const wchar *s2,size_t n)
{}


// Case insensitive wcsstr().
const wchar_t* wcscasestr(const wchar_t *str, const wchar_t *search)
{}


// Case insensitive std::wstring substring search.
std::wstring::size_type wcscasestr(const std::wstring &str, const std::wstring &search)
{}


#ifndef SFX_MODULE
wchar* wcslower(wchar *s)
{}


void wcslower(std::wstring &s)
{}


wchar* wcsupper(wchar *s)
{}


void wcsupper(std::wstring &s)
{}
#endif




int toupperw(int ch)
{}


int tolowerw(int ch)
{}


int atoiw(const std::wstring &s)
{}


int64 atoilw(const std::wstring &s)
{}


#ifdef DBCS_SUPPORTED

SupportDBCS::SupportDBCS()
{
  Init();
}


void SupportDBCS::Init()
{
  CPINFO CPInfo;
  GetCPInfo(CP_ACP,&CPInfo);
  DBCSMode=CPInfo.MaxCharSize > 1;
  for (uint I=0;I<ASIZE(IsLeadByte);I++)
    IsLeadByte[I]=IsDBCSLeadByte(I)!=0;
}

// static
SupportDBCS& SupportDBCS::GetInstance() {
  static SupportDBCS supportDBCS;
  return supportDBCS;
}

char* SupportDBCS::charnext(const char *s)
{
  // Zero cannot be the trail byte. So if next byte after the lead byte
  // is 0, the string is corrupt and we'll better return the pointer to 0,
  // to break string processing loops.
  return (char *)(IsLeadByte[(byte)*s] && s[1]!=0 ? s+2:s+1);
}
#endif