void CBC_QRDecodedBitStreamParser::DecodeAlphanumericSegment(
    CBC_CommonBitSource* bits,
    CFX_ByteString& result,
    int32_t count,
    FX_BOOL fac1InEffect,
    int32_t& e) {
  int32_t start = result.GetLength();
  while (count > 1) {
    int32_t nextTwoCharsBits = bits->ReadBits(11, e);
    BC_EXCEPTION_CHECK_ReturnVoid(e);
    BC_FX_ByteString_Append(result, 1,
                            ALPHANUMERIC_CHARS[nextTwoCharsBits / 45]);
    BC_FX_ByteString_Append(result, 1,
                            ALPHANUMERIC_CHARS[nextTwoCharsBits % 45]);
    count -= 2;
  }
  if (count == 1) {
    int32_t itemp = bits->ReadBits(6, e);
    BC_EXCEPTION_CHECK_ReturnVoid(e);
    BC_FX_ByteString_Append(result, 1, ALPHANUMERIC_CHARS[itemp]);
  }
  if (fac1InEffect) {
    for (int32_t i = start; i < result.GetLength(); i++) {
      if (result[i] == '%') {
        if ((i < result.GetLength() - 1) && result[i + 1] == '%') {
          result.Delete(i + 1, 1);
        } else {
          result.SetAt(i, (FX_CHAR)0x1d);
        }
      }
    }
  }
}
TEST(fxcrt, ByteStringConcatInPlace) {
  CFX_ByteString fred;
  fred.ConcatInPlace(4, "FRED");
  EXPECT_EQ("FRED", fred);

  fred.ConcatInPlace(2, "DY");
  EXPECT_EQ("FREDDY", fred);

  fred.Delete(3, 3);
  EXPECT_EQ("FRE", fred);

  fred.ConcatInPlace(1, "D");
  EXPECT_EQ("FRED", fred);

  CFX_ByteString copy = fred;
  fred.ConcatInPlace(2, "DY");
  EXPECT_EQ("FREDDY", fred);
  EXPECT_EQ("FRED", copy);

  // Test invalid arguments.
  copy = fred;
  fred.ConcatInPlace(-6, "freddy");
  CFX_ByteString not_aliased("xxxxxx");
  EXPECT_EQ("FREDDY", fred);
  EXPECT_EQ("xxxxxx", not_aliased);
}
Example #3
0
CFX_ByteString CBC_OnedUPCAReader::MaybeReturnResult(CFX_ByteString& result,
                                                     int32_t& e) {
  if (result[0] == '0') {
    result.Delete(0);
    return result;
  } else {
    e = BCExceptionFormatException;
    return "";
  }
  return "";
}
Example #4
0
void CPDF_DefaultAppearance::GetFont(CFX_ByteString& csFontNameTag,
                                     FX_FLOAT& fFontSize) {
  csFontNameTag = "";
  fFontSize = 0;
  if (m_csDA.IsEmpty()) {
    return;
  }
  CPDF_SimpleParser syntax(m_csDA);
  if (syntax.FindTagParam("Tf", 2)) {
    csFontNameTag = (CFX_ByteString)syntax.GetWord();
    csFontNameTag.Delete(0, 1);
    fFontSize = FX_atof((CFX_ByteString)syntax.GetWord());
  }
  csFontNameTag = PDF_NameDecode(csFontNameTag);
}