JNIEXPORT jstring JNICALL Java_com_codeminders_hidapi_HIDDevice_getIndexedString (JNIEnv *env, jobject self, jint index) { hid_device *peer = getPeer(env, self); if(!peer) { throwIOException(env, peer); return NULL; /* not an error, freed previously */ } wchar_t data[MAX_BUFFER_SIZE]; int res = hid_get_indexed_string(peer, index, data, MAX_BUFFER_SIZE); if(res < 0) { /* We decided not to treat this as an error, but return an empty string in this case throwIOException(env, peer); return NULL; */ data[0] = 0; } char *u8 = convertToUTF8(env, data); jstring string = env->NewStringUTF(u8); free(u8); return string; }
void ARRAY_TEXT::copyUTF8StringAtIndex(CUTF8String* pString, uint32_t index) { if(index < this->_CUTF16StringArray->size()) { CUTF16String s = CUTF16String(this->_CUTF16StringArray->at(index)); convertToUTF8(&s, pString); } }
BOOL CBillReview::OnCommand(WPARAM wParam, LPARAM lParam) { CViewInvoice *lpViewInvoice; BILL_ROWINFO BillRowInfo; int iReturn; m_pBillRev_DT = (CDataTbl *) GetDlgItem(IDC_BILL_REVIEW_DT); // TODO: Add your specialized code here and/or call the base class switch( HIWORD(wParam) ) { case DTN_ROWSEL: m_rSelectedRow = m_pBillRev_DT->GetNotifyRow(); iReturn = m_pBillRev_DT->SetAccessPos( (COLNUM)0, m_rSelectedRow ); break; case DTN_LFDBLCLK: case DTN_RTDBLCLK: m_rSelectedRow = m_pBillRev_DT->GetNotifyRow(); iReturn = m_pBillRev_DT->ReadRow( DTA_CURRENT, (void *)&BillRowInfo ); if( iReturn == 0 ) { convertToUTF8(BillRowInfo); if (!BillRowInfo.online) { CGuiMsg::GuiMessage(GUIMSG_BILL_IMAGE_NON_EXISTANT); break;; } lpViewInvoice = new CViewInvoice( *m_lpAccountData, BillRowInfo.bill_ref_no, BillRowInfo.bill_ref_resets ); lpViewInvoice->DoModal(); delete lpViewInvoice; } else { CGuiMsg::GuiMessage(GUIMSG_BIB_NO_ROW_SELECTED); } break; } return CDialog::OnCommand(wParam, lParam); }
static void dumpSvgLine(XtermWidget xw, int row, FILE *fp) { TScreen *s = TScreenOf(xw); int inx = ROW2INX(s, row); LineData *ld = getLineData(s, inx); int col, sal, i; /* sal: same attribute length */ if (ld == 0) return; for (col = 0; col < MaxCols(s); col += sal) { XColor fgcolor, bgcolor; /* Count how many consecutive cells have the same color & attributes. */ for (sal = 1; col + sal < MaxCols(s); ++sal) { #if OPT_ISO_COLORS if (ld->color[col] != ld->color[col + sal]) break; #endif if (ld->attribs[col] != ld->attribs[col + sal]) break; } fgcolor.pixel = xw->old_foreground; bgcolor.pixel = xw->old_background; #if OPT_ISO_COLORS if (ld->attribs[col] & FG_COLOR) { unsigned fg = extract_fg(xw, ld->color[col], ld->attribs[col]); fgcolor.pixel = s->Acolors[fg].value; } if (ld->attribs[col] & BG_COLOR) { unsigned bg = extract_bg(xw, ld->color[col], ld->attribs[col]); bgcolor.pixel = s->Acolors[bg].value; } #endif XQueryColor(xw->screen.display, xw->core.colormap, &fgcolor); XQueryColor(xw->screen.display, xw->core.colormap, &bgcolor); if (ld->attribs[col] & BLINK) { /* White on red. */ fgcolor.red = fgcolor.green = fgcolor.blue = 65535u; bgcolor.red = 65535u; bgcolor.green = bgcolor.blue = 0u; } #if OPT_WIDE_ATTRS if (ld->attribs[col] & ATR_FAINT) { fgcolor.red = (unsigned short) ((2 * fgcolor.red) / 3); fgcolor.green = (unsigned short) ((2 * fgcolor.green) / 3); fgcolor.blue = (unsigned short) ((2 * fgcolor.blue) / 3); } #endif if (ld->attribs[col] & INVERSE) { XColor tmp = fgcolor; fgcolor = bgcolor; bgcolor = tmp; } /* Draw the background rectangle. */ fprintf(fp, " <rect x='%d' y='%d' ", bw + ib + col * CELLW, bw + ib + row * CELLH); fprintf(fp, "height='%d' width='%d' ", CELLH, sal * CELLW); fprintf(fp, "fill='rgb(%.2f%%, %.2f%%, %.2f%%)'/>\n", RGBPCT(bgcolor)); /* Now the <text>. */ /* * SVG: Rendering text strings into a given rectangle is a challenge. * Some renderers accept and do the right thing with the 'textLength' * attribute, while others ignore it. The only predictable way to place * (even monospaced) text properly is to do it character by character. */ fprintf(fp, " <g"); if (ld->attribs[col] & BOLD) fprintf(fp, " font-weight='bold'"); #if OPT_WIDE_ATTRS if (ld->attribs[col] & ATR_ITALIC) fprintf(fp, " font-style='italic'"); #endif fprintf(fp, " fill='rgb(%.2f%%, %.2f%%, %.2f%%)'>\n", RGBPCT(fgcolor)); for (i = 0; i < sal; ++i) { IChar chr = ld->charData[col + i]; if (chr == ' ') continue; fprintf(fp, " <text x='%d' y='%d'>", bw + ib + (col + i) * CELLW, bw + ib + row * CELLH + (CELLH * 3) / 4); #if OPT_WIDE_CHARS if (chr > 127) { /* Ignore hidden characters. */ if (chr != HIDDEN_CHAR) { Char temp[10]; *convertToUTF8(temp, chr) = 0; fputs((char *) temp, fp); } } else #endif switch (chr) { case 0: /* This sometimes happens when resizing... ignore. */ break; case '&': fputs("&", fp); break; case '<': fputs("<", fp); break; case '>': fputs(">", fp); break; default: fputc((int) chr, fp); } fprintf(fp, "</text>\n"); } fprintf(fp, " </g>\n"); #define HLINE(x) \ fprintf(fp, " <line x1='%d' y1='%d' " \ "x2='%d' y2='%d' " \ "stroke='rgb(%.2f%%, %.2f%%, %.2f%%)'/>\n", \ bw + ib + col * CELLW, bw + ib + row * CELLH + CELLH - (x), \ bw + ib + (col + sal) * CELLW, bw + ib + row * CELLH + CELLH - (x), \ RGBPCT(fgcolor)) /* Now the line attributes. */ if (ld->attribs[col] & UNDERLINE) { HLINE(4); } #if OPT_WIDE_ATTRS if (ld->attribs[col] & ATR_STRIKEOUT) { HLINE(9); } if (ld->attribs[col] & ATR_DBL_UNDER) { HLINE(3); HLINE(1); } #endif } }
static void newJavaGD_Text(double x, double y, constxt char *str, double rot, double hadj, R_GE_gcontext *gc, NewDevDesc *dd) { newJavaGD_TextUTF8(x, y, convertToUTF8(str, gc), rot, hadj, gc, dd); }
static double newJavaGD_StrWidth(constxt char *str, R_GE_gcontext *gc, NewDevDesc *dd) { return newJavaGD_StrWidthUTF8(convertToUTF8(str, gc), gc, dd); }