The following problem arose when the qr code generation module was connected, https://github.com/monospaced/angular-qrcode to the project, which would not be done when entering Russian letters, the resulting qr code is interpreted in the wrong encoding.

The js file is stored in utf-8 encoding. Example: "Hello world" is obtained as "? @ 825B <8 @".

The decoder says that it is 7-bit ASCII → KOI8-U + KOI8-R → ISO-8859-5 , but I don’t understand how it is. I tried to save the file in different encodings at the output I get - "??????????".

In the demo example to the module, there are no problems with Russian letters, tell me in which direction to dig.

An example of code like this:

<div class="block-qr"> <qrcode version="8" error-correction-level="Medium" size="400" data="{{vm.data}}" href="{{var}}" download></qrcode> </div> <form class="block-form"> <div class="form-group"> <label>Заголовок</label> <input type="text" class="form-control" placeholder="Заголовок" ng-model="vm.title"> </div> <div class="form-group"> <label>Организация</label> <input type="text" class="form-control" placeholder="Организация" ng-model="vm.org"> </div> <div class="form-group"> <label></label>Телефон</label> <input type="text" class="form-control" placeholder="Телефон" ng-model="vm.phone"> </div> <div class="form-group"> <label for="exampleInputEmail1">Email</label> <input type="email" class="form-control" placeholder="Email" id="exampleInputEmail1" ng-model="vm.emails"> </div> <div class="form-group"> <label>Сайт</label> <input type="text" class="form-control" placeholder="Сайт" ng-model="vm.site"> </div> <button type="submit" class="btn btn-default" ng-click="vm.concat()">Сгенерировать</button> </form> 

And controller:

 function concat() { vm.data = 'Title: ' + vm.title + '\nOrg: ' + vm.org + '\nPhone number: ' + vm.phone + '\nEmail: ' + vm.emails + '\n ' + vm.site; return vm.data; } 

Actually for the Latin no problems, everything works fine.

  • How do you check the data in qr code? - Stepan Kasyanenko
  • Checking these problems is not a lot of applications on the phone. - Alexander

1 answer 1

The problem is that you apparently did not connect all the necessary scripts.

Namely, support for UTF-8 .

If you look at an example of use , we will see that the script http://monospaced.imtqy.com/bower-qrcode-generator/js/qrcode_UTF8.js is connected there.

Check out the jsfiddle example.

 angular.module('ExampleApp', ['monospaced.qrcode']) .controller('ExampleController', function() { }); 
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <script src="https://rawgit.com/kazuhikoarase/qrcode-generator/master/js/qrcode.js"></script> <script src="https://rawgit.com/kazuhikoarase/qrcode-generator/master/js/qrcode_UTF8.js"></script> <script src="https://rawgit.com/monospaced/angular-qrcode/master/angular-qrcode.js"></script> <div ng-app="ExampleApp"> <div ng-controller="ExampleController as vm"> <label>Сайт</label> <input type="text" class="form-control" placeholder="Сайт" ng-model="vm.site"> <qrcode data="{{vm.site}}"></qrcode> </div> </div> 

  • Thanks for the tip, I'll check it out. - Alexander
  • I didn’t notice the elephant, thanks, when installing through bower, 2 angular-qrcode and qrcode-generator folders are installed, I actually connected the script from the first folder, everything worked, but without Latin support, adding the remaining scripts everything began to work as needed. - Alexander