mirror of
https://github.com/zxing/zxing.git
synced 2024-11-10 13:04:05 -08:00
formatting only
git-svn-id: https://zxing.googlecode.com/svn/trunk@1839 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
0d4ae9fef6
commit
395cdb0f24
|
@ -1,4 +1,5 @@
|
|||
/*
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* DecodedBitStreamParser.cpp
|
||||
* zxing
|
||||
*
|
||||
|
@ -37,22 +38,22 @@
|
|||
using namespace zxing;
|
||||
|
||||
namespace zxing {
|
||||
namespace qrcode {
|
||||
namespace qrcode {
|
||||
|
||||
using namespace std;
|
||||
using namespace std;
|
||||
|
||||
const char DecodedBitStreamParser::ALPHANUMERIC_CHARS[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
|
||||
const char DecodedBitStreamParser::ALPHANUMERIC_CHARS[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
|
||||
'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
|
||||
'Y', 'Z', ' ', '$', '%', '*', '+', '-', '.', '/', ':'
|
||||
};
|
||||
|
||||
const char *DecodedBitStreamParser::ASCII = "ASCII";
|
||||
const char *DecodedBitStreamParser::ISO88591 = "ISO-8859-1";
|
||||
const char *DecodedBitStreamParser::UTF8 = "UTF-8";
|
||||
const char *DecodedBitStreamParser::SHIFT_JIS = "SHIFT_JIS";
|
||||
const char *DecodedBitStreamParser::EUC_JP = "EUC-JP";
|
||||
const char *DecodedBitStreamParser::ASCII = "ASCII";
|
||||
const char *DecodedBitStreamParser::ISO88591 = "ISO-8859-1";
|
||||
const char *DecodedBitStreamParser::UTF8 = "UTF-8";
|
||||
const char *DecodedBitStreamParser::SHIFT_JIS = "SHIFT_JIS";
|
||||
const char *DecodedBitStreamParser::EUC_JP = "EUC-JP";
|
||||
|
||||
void DecodedBitStreamParser::append(std::string &result, const unsigned char *bufIn, size_t nIn, const char *src) {
|
||||
void DecodedBitStreamParser::append(std::string &result, const unsigned char *bufIn, size_t nIn, const char *src) {
|
||||
#ifndef NO_ICONV
|
||||
if (nIn == 0) {
|
||||
return;
|
||||
|
@ -81,12 +82,12 @@ void DecodedBitStreamParser::append(std::string &result, const unsigned char *bu
|
|||
bufOut[nResult] = '\0';
|
||||
result.append((const char *)bufOut);
|
||||
delete[] bufOut;
|
||||
#else
|
||||
#else
|
||||
result.append((const char *)bufIn, nIn);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void DecodedBitStreamParser::decodeKanjiSegment(Ref<BitSource> bits, std::string &result, int count) {
|
||||
void DecodedBitStreamParser::decodeKanjiSegment(Ref<BitSource> bits, std::string &result, int count) {
|
||||
// Each character will require 2 bytes. Read the characters as 2-byte pairs
|
||||
// and decode as Shift_JIS afterwards
|
||||
size_t nBytes = 2 * count;
|
||||
|
@ -112,9 +113,9 @@ void DecodedBitStreamParser::decodeKanjiSegment(Ref<BitSource> bits, std::string
|
|||
|
||||
append(result, buffer, nBytes, SHIFT_JIS);
|
||||
delete[] buffer;
|
||||
}
|
||||
}
|
||||
|
||||
void DecodedBitStreamParser::decodeByteSegment(Ref<BitSource> bits, std::string &result, int count) {
|
||||
void DecodedBitStreamParser::decodeByteSegment(Ref<BitSource> bits, std::string &result, int count) {
|
||||
int nBytes = count;
|
||||
unsigned char* readBytes = new unsigned char[nBytes];
|
||||
if (count << 3 > bits->available()) {
|
||||
|
@ -134,9 +135,9 @@ void DecodedBitStreamParser::decodeByteSegment(Ref<BitSource> bits, std::string
|
|||
const char *encoding = guessEncoding(readBytes, nBytes);
|
||||
append(result, readBytes, nBytes, encoding);
|
||||
delete[] readBytes;
|
||||
}
|
||||
}
|
||||
|
||||
void DecodedBitStreamParser::decodeNumericSegment(Ref<BitSource> bits, std::string &result, int count) {
|
||||
void DecodedBitStreamParser::decodeNumericSegment(Ref<BitSource> bits, std::string &result, int count) {
|
||||
int nBytes = count;
|
||||
unsigned char* bytes = new unsigned char[nBytes];
|
||||
int i = 0;
|
||||
|
@ -179,9 +180,9 @@ void DecodedBitStreamParser::decodeNumericSegment(Ref<BitSource> bits, std::stri
|
|||
}
|
||||
append(result, bytes, nBytes, ASCII);
|
||||
delete[] bytes;
|
||||
}
|
||||
}
|
||||
|
||||
void DecodedBitStreamParser::decodeAlphanumericSegment(Ref<BitSource> bits, std::string &result, int count) {
|
||||
void DecodedBitStreamParser::decodeAlphanumericSegment(Ref<BitSource> bits, std::string &result, int count) {
|
||||
int nBytes = count;
|
||||
unsigned char* bytes = new unsigned char[nBytes];
|
||||
int i = 0;
|
||||
|
@ -197,10 +198,10 @@ void DecodedBitStreamParser::decodeAlphanumericSegment(Ref<BitSource> bits, std:
|
|||
}
|
||||
append(result, bytes, nBytes, ASCII);
|
||||
delete[] bytes;
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
DecodedBitStreamParser::guessEncoding(unsigned char *bytes, int length) {
|
||||
const char *
|
||||
DecodedBitStreamParser::guessEncoding(unsigned char *bytes, int length) {
|
||||
const bool ASSUME_SHIFT_JIS = false;
|
||||
char const* const PLATFORM_DEFAULT_ENCODING="UTF-8";
|
||||
|
||||
|
@ -316,9 +317,9 @@ DecodedBitStreamParser::guessEncoding(unsigned char *bytes, int length) {
|
|||
}
|
||||
// Otherwise, we take a wild guess with platform encoding
|
||||
return PLATFORM_DEFAULT_ENCODING;
|
||||
}
|
||||
}
|
||||
|
||||
string DecodedBitStreamParser::decode(ArrayRef<unsigned char> bytes, Version *version) {
|
||||
string DecodedBitStreamParser::decode(ArrayRef<unsigned char> bytes, Version *version) {
|
||||
string result;
|
||||
Ref<BitSource> bits(new BitSource(bytes));
|
||||
Mode *mode = &Mode::TERMINATOR;
|
||||
|
@ -347,7 +348,7 @@ string DecodedBitStreamParser::decode(ArrayRef<unsigned char> bytes, Version *ve
|
|||
}
|
||||
} while (mode != &Mode::TERMINATOR);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue