Exemplo n.º 1
0
int
compare_wide_to_latin1 (wchar_t *wbox1, long n1, unsigned char *box2, long n2)
{
  wchar_t temp;
  long inx = 0;
  while (1)
    {
      if (inx == n1)	/* box1 in end? */
	{
	  if (inx == n2)
	    return DVC_MATCH;  /* box2 of same length */
	  else
	    return DVC_LESS;   /* otherwise box1 is shorter than box2 */
	}
      if (inx == n2)
	return DVC_GREATER;	/* box2 in end (but not box1) */
      temp = CHAR_TO_WCHAR (box2[inx], NULL);
      if (wbox1[inx] < temp)
	return DVC_LESS;
      if (wbox1[inx] > temp)
	return DVC_GREATER;
      inx++;
    }
  /*NOTREACHED*/
  return DVC_LESS;
}
Exemplo n.º 2
0
caddr_t
box_narrow_string_as_wide (unsigned char *str, caddr_t wide, long max_len, wcharset_t *charset, caddr_t * err_ret, int isbox)
{
  long i, len = (long)(isbox ? (box_length ((box_t) str) - 1) : strlen((const char *) str));
  wchar_t *box;
  size_t wide_len;
  if (!charset)
    {
      client_connection_t *cli = GET_IMMEDIATE_CLIENT_OR_NULL;
      if (cli)
	charset = cli->cli_charset;
    }
  if (!charset)
    charset = default_charset;


  if (max_len > 0 && len > max_len)
    len = max_len;
/*  if (len == 0)
    return NULL; - explicit bug */
  wide_len = (len + 1) * sizeof(wchar_t);
  if (wide_len > MAX_READ_STRING)
    {
      if (err_ret)
	*err_ret = srv_make_new_error ("22023", "SR578", "The expected result length of wide string is too large");
      return NULL;
    }
  box = (wchar_t *) (wide ? wide : dk_alloc_box_zero (wide_len, DV_WIDE));
  for (i = 0; i < len; i++)
    box[i] = CHAR_TO_WCHAR(str[i], charset);
  box[len] = L'\0';
  return ((caddr_t) box);
}
NJ_INT16 nje_convert_hira_to_kata(NJ_CHAR *hira, NJ_CHAR *kata, NJ_UINT16 len)
{
    NJ_UINT16 pnt;
    NJ_UINT16 wchar;


    pnt = 0;
    while (pnt < len) {
        if (*hira == NJ_CHAR_NUL) {
            
            return pnt;
        }

        
        wchar = CHAR_TO_WCHAR(hira);
        hira++;
        pnt++;

        if (IS_HIRAGANA_WCHAR(wchar)) {
            
            SET_WCHAR_TO_CHAR(kata, wchar + HIRA_KATA_OFFSET);
            kata += ZEN_CHAR_LEN;
        } else {
            SET_WCHAR_TO_CHAR(kata, wchar);
            kata += ZEN_CHAR_LEN;
        }
    }

    
    *kata = NJ_CHAR_NUL;
    return pnt;
}
Exemplo n.º 4
0
static int
print_narrow_string_as_wide (dk_session_t *ses, unsigned char *string, wcharset_t *charset)
{
  unsigned char *pstr = string;
  long utf8_len = 0, char_utf8_len;
  virt_mbstate_t state;
  wchar_t wchar;
  unsigned char mbs[VIRT_MB_CUR_MAX];

  memset (&state, 0, sizeof (virt_mbstate_t));
  while (*pstr)
    {
      wchar = CHAR_TO_WCHAR (*pstr, charset);
      char_utf8_len = (long) virt_wcrtomb (mbs, wchar, &state);
      if (char_utf8_len < 1)
	return char_utf8_len;
      utf8_len += char_utf8_len;
      pstr += 1;
    }
  if (utf8_len < 256)
    {
      session_buffered_write_char (DV_WIDE, ses);
      session_buffered_write_char ((char) utf8_len, ses);
    }
  else
    {
      session_buffered_write_char (DV_LONG_WIDE, ses);
      print_long (utf8_len, ses);
    }

  memset (&state, 0, sizeof (virt_mbstate_t));
  pstr = string;
  while (*pstr)
    {
      wchar = CHAR_TO_WCHAR (*pstr, charset);
      char_utf8_len = (long) virt_wcrtomb (mbs, wchar, &state);
      session_buffered_write (ses, (char *) mbs, char_utf8_len);
      pstr += 1;
    }
  return utf8_len;
}
Exemplo n.º 5
0
	//input the output data string,and analyze it
	bool	cPrtStartPositionInitByFrame::SetDataByDataString(char*e_pString)
	{
		char*Nexttoken = 0;
		char* l_pString = strtok(e_pString,",");
		m_eAttachFrameType = (eAttachFrameType)atoi(l_pString);

		l_pString = strtok(0,",");
		if( m_eAttachFrameType != eAFT_CAMERA )
		{
			assert(0&&"current not support");
			//wchar_t	l_tempForGetObject[MAX_PATH];
			//CHAR_TO_WCHAR(l_pString,l_tempForGetObject);
			//m_pFrame = g_pPrt->GetMeshList()->GetObject(l_tempForGetObject);
			//CT::ErrorMsg(m_pFrame?true:false,l_pString,"can't find mesh");
		}
		l_pString = strtok(0,",");
		CHAR_TO_WCHAR(l_pString,m_psSubFrameName);
		l_pString = strtok(0,",");//offset pos x
		this->m_vOffsetPos.x = (float)atof(l_pString);
		l_pString = strtok(0,",");//offset pos y
		this->m_vOffsetPos.y = (float)atof(l_pString);
		l_pString = strtok(0,",");//offset pos z
		this->m_vOffsetPos.z = (float)atof(l_pString);
		if( strtok(0,",") )
			return false;
		switch(m_eAttachFrameType)
		{
			case eAFT_CAMERA:
				assert(0&&"current not support");
				//m_pFrame = g_pEngine->m_pCamera;
				break;
			case eAFT_FRAME_OF_FRAME:
				if( m_pFrame )
				{
					assert(0&&"current not support");
					//cGameApp::OutputDebugInfoString(L"!!----I am lazy to write more flexible,support Frame-----!!\n");
					//if( m_pFrame->Type() == MESH::CDXUTMeshFrame::TypeID || 
					//	m_pFrame->Type() == MESH::CDXUTMeshFile::TypeID )
					//{
					//	MESH::CDXUTMeshFrame*l_pFrame = (MESH::CDXUTMeshFrame*)m_pFrame;
					//	m_pSubFrameOfModel = l_pFrame->FindMesh(m_psSubFrameName);
					//	CT::ErrorMsgW(m_pSubFrameOfModel?true:false,m_psSubFrameName,L"not exist");
					//}
					//else
					//	assert(0&&"eAFT_FRAME_OF_FRAME type error");
				}
				break;
			case eAFT_FRAME_OF_MESH:
				assert(0&&"current not support");
				//if( m_pFrame )
				//if( m_pFrame->Type() == MESH::CAnimationAgent::TypeID )
				//{
				//	CHAR	l_tempStringForFrame[MAX_PATH];
				//	WCHAR_TO_CHAR(m_psSubFrameName,l_tempStringForFrame);
				//	MESH::CAnimationAgent*l_p = (MESH::CAnimationAgent*)m_pFrame;
				//	this->m_pD3DMatrix = CT::GetFrameMatrixByName(l_tempStringForFrame,l_p->GetRootFrame());
				//	CT::ErrorMsgW(m_pD3DMatrix?true:false,m_psSubFrameName,L"not exist");
				//}
				break;
		}
		return true;
	}
Exemplo n.º 6
0
int
parse_wide_string_literal (unsigned char **str_ptr, caddr_t box, wcharset_t *charset)
{
  unsigned int i = 0;
  volatile unsigned int q;
  wchar_t z;
  UCHAR *str = (**str_ptr == 'N' || **str_ptr == 'n') ? *str_ptr + 1 : *str_ptr;
  UCHAR beg_quote = *str++;	/* And skip past N and it. */
  wchar_t c;
  wchar_t *result = (wchar_t *)box;
  if (!charset)
    {
      client_connection_t *cli = GET_IMMEDIATE_CLIENT_OR_NULL;
      if (cli)
	charset = cli->cli_charset;
    }
  if (!charset)
    charset = default_charset;


  for (/* no init */; '\0' != str[0]; str++)
    {
      switch (str[0])
	{
	case '\\':		/* An escaped character follows? */
	  {

	    if (!parse_not_char_c_escape)
	      {
		/* New escapes added 23.AUG.1991 \a for bell, and \v for vertical tab
		   as specified in ANSI C standard. Also now recognizes hexadecimal
		   character constants beginning with \x Note that \e for escape
		   does not belong to standard. (Commented out)
		 */
		switch (*++str)	/* Check the next character. */
		  {
		    /* If a string anomalously ends with a trailing (single) backslash, then
		       leave it dangling there: */
		    case '\0':
			{
			  c = CHAR_TO_WCHAR(*(str - 1), charset);
			  break;
			}
		    case 'a':
			  {
			    c = (wchar_t)7;
			    break;
			  }		/* BEL audible alert */
		    case 'b':
			    {
			      c = (wchar_t)'\b';
			      break;
			    }		/* BS  backspace */
			    /*	      case 'e': { c = '\033'; break; } *//* ESC escape */
		    case 'f':
			      {
				c = (wchar_t)'\f';
				break;
			      }		/* FF  form feed */
		    case 'n':
				{
				  c = (wchar_t)'\n';
				  break;
				}		/* NL (LF) newline */
		    case 'r':
				  {
				    c = (wchar_t)'\r';
				    break;
				  }		/* CR  carriage return */
		    case 't':
				    {
				      c = (wchar_t)'\t';
				      break;
				    }		/* HT  horizontal tab */
		    case 'v':
				      {
					c = (wchar_t)'\013';
					break;
				      }		/* VT  vertical tab */
		    case 'x':	/* There's a hexadecimal char constant \xhh */
		    case 'X':
					{		/* We should check that only max 2 digits are parsed */
					  q = 4;
					  z = 0;
					  str++;
					  while (*str && isxdigit (*str) && (q--))
					    {
					      z = ((z << 4) + (isdigit (*str) ?
						    (*str - '0') : (toupper (*str) - 'A' + 10)));
					      str++;
					    }
					  c = z;
					  if (!z)
					    return -1;
					  str--;	/* str is incremented soon. */
					  break;
					}
		    case '0':
		    case '1':
		    case '2':
		    case '3':
		    case '4':
		    case '5':
		    case '6':
		    case '7':
					  {		/* So it's an octal sequence like \033 : */
					    q = 6;
					    z = 0;
					    while (isoctdigit (*str) && (q--))
					      {
						z = ((z << 3) + (*str++ - '0'));
					      }
					    c = z;
					    str--;	/* str is incremented soon. */
					    if (!z)
					      return -1;
					    break;
					  }		/* octal digits */
			/* \\\n should not appear in the output at all */
		    case '\n':
		    case '\r':
			continue;
		    default:		/* Every other character after backslash produces */
					    {		/* that same character, i.e. \\ = \, \' = ', etc. */
					      c = CHAR_TO_WCHAR(*str, charset);
					      break;
					    }		/* default */

		  }			/* inner switch for character after a backslash */
		if (result)
		  result[i] = c;
		i++;
		break;
	      } /* if for processing backslashes */
	  }			/* case for backslash. */
	default:
	  {
	    if (*str == beg_quote)
	      {
		/* If the next char is a quote also, then this is not yet
		   the terminating quote */
		if (*(str + 1) == beg_quote)
		  {
		    str++;	/* Skip that quote next time. */
		    goto copy_char;
		  }
		else
		  {		/* String is terminated. */
		    goto out;
		  }
	      }
	    else
	      /* Any other character. */
	      {
	      copy_char:
		if (result)
		  result[i] = CHAR_TO_WCHAR(*str, charset);
		i++;
		break;
	      }
	  }
	}			/* outer switch */
    }				/* for loop */
out:;
  if (result)
    {
      result[i] = L'\0';
    }				/* Put a terminating zero. */
  if (*str)			/* The terminating quote is here. */
    {
      *str_ptr = str + 1;	/* Skip past it. */
    }
  else
    {
      /* The terminating quote is missing, we should produce an error here! */
      *str_ptr = str;		/* But in this version we are tolerant of that. */
    }
  return ((i + 1) * sizeof(wchar_t));			/* Return the length. */
}