Hello,

I wonder how do you calculate a headline length for double-width characters.
I could not find a proper definition of "double-width" character.

And if for example I take a headline like  "a₹", while creating an Ad 
through Adwords UI I see that the length is 3.

Double-width <https://support.google.com/partners/answer/1704389> 
characters count as two characters for the purpose of this limit.

But if I get utf-8 bytes of this String, it is 4, because "a" is 1 byte and 
"₹" is 3 bytes.

So I use this Java code to match the Google way of calculating the length:

String s = "a₹";
int charsLength = s.length();
int bytesLength = s.getBytes("UTF-8").length;
int googleLength = charsLength + (bytesLength - charsLength) / 2;
System.out.println("String length: " + charsLength);
System.out.println("Bytes length: " + bytesLength);
System.out.println("Google length: " + googleLength);

but I am not sure this is the correct way.

Can you please advise what is the correct way of calculating the string 
length to match it with the way you calculate it for the limits?

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/7ca9ed7a-ce41-4bc2-bc67-bebc9729f4d7%40googlegroups.com.

Reply via email to