/*********************************************************************
*
*       GUI_UC_ConvertUC2UTF8
*/
int GUI_UC_ConvertUC2UTF8(const U16 GUI_UNI_PTR * s, int Len, char * pBuffer, int BufferSize) {
  int LenDest;
  LenDest = 0;
  GUI_LOCK();
  while (Len--) {
    int NumBytes;
    NumBytes = GUI_UC_Encode(pBuffer, *s++);
    if ((LenDest + NumBytes) > BufferSize) {
      break;
    }
    pBuffer += NumBytes;
    LenDest += NumBytes;
  }
  GUI_UNLOCK();
  return LenDest;
}
Esempio n. 2
0
/*********************************************************************
*
*       _InsertChar
*
* Create space at the current cursor position and inserts a character.
*/
static int _InsertChar(EDIT_Handle hObj, EDIT_Obj* pObj, U16 Char) {
  if (_IsCharsAvailable(pObj, 1)) {
    int BytesNeeded;
    BytesNeeded = GUI_UC__CalcSizeOfChar(Char);
    if (_IsSpaceInBuffer(pObj, BytesNeeded)) {
      int CursorOffset;
      char* pText;
      pText = (char*) GUI_ALLOC_h2p(pObj->hpText);
      CursorOffset = GUI_UC__NumChars2NumBytes(pText, pObj->CursorPos);
      pText += CursorOffset;
      memmove(pText + BytesNeeded, pText, strlen(pText) + 1);
      GUI_UC_Encode(pText, Char);
      WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED);
      return 1;
    }
  }
  return 0;
}