nBill Community nBill Home Page
23/May/2012, 12:38:18 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Click Here for the nBill home page, or take a tour.  
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: windows-1251 charset and Order Forms  (Read 6500 times)
smartcall
Jr. Member
**
Offline Offline

Posts: 6


View Profile
« on: 04/December/2007, 04:10:17 PM »

Hello.
I downloaded the latest version and received demo license. All went well up to the moment when I tried to create an order form.
I need the dropdown descriptions, for example, to be in windows-1251 encoding. After I submit and try to edit or view the form in the frontend the descriptions are either blank or show unreadable characters.
My site is in windows-1251 encoding.
It is too late for me to switch to UTF-8, because I will have a lot of work in order to do that. What could you suggest?
Is your component capable of handling non latin and non utf8 encodings?
Logged
netshine
Administrator
Hero Member
*****
Offline Offline

Posts: 4,563


View Profile
« Reply #1 on: 04/December/2007, 10:08:17 PM »

I believe the encoding is handled by entirely by Joomla, and your database, rather than nBill. There are no specific provisions in nBill for changing the encoding.
Logged
smartcall
Jr. Member
**
Offline Offline

Posts: 6


View Profile
« Reply #2 on: 05/December/2007, 06:16:36 AM »

Good, but then why only nBill behaves that way? And especially in order form editor. Nowhere else.
Logged
netshine
Administrator
Hero Member
*****
Offline Offline

Posts: 4,563


View Profile
« Reply #3 on: 05/December/2007, 08:29:43 AM »

I honestly don't know, but I will see if I can find out.
Logged
smartcall
Jr. Member
**
Offline Offline

Posts: 6


View Profile
« Reply #4 on: 05/December/2007, 08:44:02 AM »

Thank you. Otherwize this great component is useless at least to me for this particular site.
I could switch to utf-8, but this would be a hard job (database, lots of language files, etc.)
Logged
netshine
Administrator
Hero Member
*****
Offline Offline

Posts: 4,563


View Profile
« Reply #5 on: 05/December/2007, 10:21:42 AM »

It might be something to do with the javascript function that base64 encodes data that moves between the main screen and the popup forms. If you are feeling adventurous, you could try populating the information directly in your database using the jos_inv_order_form_fields and jos_inv_order_form_fields_options tables (take a backup first). If it is that base64 routine causing the problem, this should work for you.
Logged
smartcall
Jr. Member
**
Offline Offline

Posts: 6


View Profile
« Reply #6 on: 05/December/2007, 10:53:00 AM »

I figured it might be that. I can populate the fields directly, but this is in case I have a few things to populate. Can you tell me which file to take a look at, where this function is?
Logged
netshine
Administrator
Hero Member
*****
Offline Offline

Posts: 4,563


View Profile
« Reply #7 on: 05/December/2007, 02:10:22 PM »

The file is encrypted I'm afraid. However, the Javascript functions that are being used for base64 encoding and decoding are as follows:

Code:
<script type="text/javascript">
/*PROJECT: Javascript Based Base64 Encoding and Decoding Engine

DATE: 02/10/2004

AUTHOR: Adrian Bacon

DESCRIPTION:Encode and decode data to and from the Base64 format
in Javascript. This could be used to convert encrypted
data to text for submitting via http gets or posts or
for sending via email or other text only mediums.

COPYRIGHT: You are free to use this code as you see fit provided
that you send any changes or modifications back to me.*/

//First things first, set up our array that we are going to use.
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + //all caps
"abcdefghijklmnopqrstuvwxyz" + //all lowercase
"0123456789+/="; // all numbers plus +/=

//Heres the encode function
function encode64(inp)
{
var out = ""; //This is the output
var chr1, chr2, chr3 = ""; //These are the 3 bytes to be encoded
var enc1, enc2, enc3, enc4 = ""; //These are the 4 encoded bytes
var i = 0; //Position counter

if (inp.length == 0)
{
  return out;
}
do { //Set up the loop here
chr1 = inp.charCodeAt(i++); //Grab the first byte
chr2 = inp.charCodeAt(i++); //Grab the second byte
chr3 = inp.charCodeAt(i++); //Grab the third byte

//Here is the actual base64 encode part.
//There really is only one way to do it.
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;

if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}

//Lets spit out the 4 encoded bytes
out = out + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) +
keyStr.charAt(enc4);

// OK, now clean out the variables used.
chr1 = chr2 = chr3 = "";
enc1 = enc2 = enc3 = enc4 = "";

} while (i < inp.length); //And finish off the loop

//Now return the encoded values.
return out;
}

//Heres the decode function
function decode64(inp)
{
var out = ""; //This is the output
var chr1, chr2, chr3 = ""; //These are the 3 decoded bytes
var enc1, enc2, enc3, enc4 = ""; //These are the 4 bytes to be decoded
var i = 0; //Position counter

if (inp.length == 0)
{
  return out;
}

// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
var base64test = /[^A-Za-z0-9\+\/\=]/g;

if (base64test.exec(inp)) { //Do some error checking
alert("There were invalid base64 characters in the input text.\n" +
"Valid base64 characters are A-Z, a-z, 0-9, ?+?, ?/?, and ?=?\n" +
"Expect errors in decoding.");
}
inp = inp.replace(/[^A-Za-z0-9\+\/\=]/g, "");

do { //Here ??s the decode loop.

//Grab 4 bytes of encoded content.
enc1 = keyStr.indexOf(inp.charAt(i++));
enc2 = keyStr.indexOf(inp.charAt(i++));
enc3 = keyStr.indexOf(inp.charAt(i++));
enc4 = keyStr.indexOf(inp.charAt(i++));

//Heres the decode part. There ??s really only one way to do it.
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;

//Start to output decoded content
out = out + String.fromCharCode(chr1);

if (enc3 != 64) {
out = out + String.fromCharCode(chr2);
}
if (enc4 != 64) {
out = out + String.fromCharCode(chr3);
}

//now clean out the variables used
chr1 = chr2 = chr3 = "";
enc1 = enc2 = enc3 = enc4 = "";

} while (i < inp.length); //finish off the loop

//Now return the decoded values.
return out;
}
Logged
smartcall
Jr. Member
**
Offline Offline

Posts: 6


View Profile
« Reply #8 on: 05/December/2007, 02:39:20 PM »

Looks like you remove all non-latin characters, or am I wrong
Logged
netshine
Administrator
Hero Member
*****
Offline Offline

Posts: 4,563


View Profile
« Reply #9 on: 05/December/2007, 08:20:46 PM »

I have no idea - I didn't write the functions, they are in the public domain. I will see if I can change things round a bit so that base64 encoding is not necessary.
Logged
smartcall
Jr. Member
**
Offline Offline

Posts: 6


View Profile
« Reply #10 on: 06/December/2007, 07:48:00 AM »

That would be great. Because as I can see this function doesn't allow non-latin characters.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!