Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ZXISBNResultParser.m 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright 2012 ZXing authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "ZXISBNParsedResult.h"
  17. #import "ZXISBNResultParser.h"
  18. @implementation ZXISBNResultParser
  19. /**
  20. * See <a href="http://www.bisg.org/isbn-13/for.dummies.html">ISBN-13 For Dummies</a>
  21. */
  22. - (ZXParsedResult *)parse:(ZXResult *)result {
  23. ZXBarcodeFormat format = [result barcodeFormat];
  24. if (format != kBarcodeFormatEan13) {
  25. return nil;
  26. }
  27. NSString *rawText = [ZXResultParser massagedText:result];
  28. NSUInteger length = [rawText length];
  29. if (length != 13) {
  30. return nil;
  31. }
  32. if (![rawText hasPrefix:@"978"] && ![rawText hasPrefix:@"979"]) {
  33. return nil;
  34. }
  35. return [ZXISBNParsedResult isbnParsedResultWithIsbn:rawText];
  36. }
  37. @end