8 votes
Accepted

Unable to read ANSI file in apex code?

I hacked a Apex Charset encoder/decoder util, check gist Charset.cls /** * Convenience method that decodes bytes in charset into a string of Unicode * characters. * <p> * @param input ...
nxtr's user avatar
  • 96
6 votes
Accepted

URL Encoding String with just Plus Signs

Consider using PageReference instead: Lead l = new Lead(Est_Credit_Score__c='999', Phone='(999) 555-1212', FirstName='Brian', LastName='Fear', email='[email protected]')...
sfdcfox's user avatar
  • 481k
5 votes
Accepted

VisualForce MultiLine UTF-8 CSV

OK, I have a plausible solution for Excel for Mac users. First, the options that I considered but rejected: Windows-1252 encoding - Doesn't support Asian languages UTF-16LE encoding - Creates user ...
cropredy's user avatar
  • 69.9k
4 votes
Accepted

Save text in Document object of Salesforce in ISO-8859-1/ANSI/ASCII format

The String type in Salesforce is always a UTF-8 String. The most practical way to make sure it's an actual ISO-8859-1 string is to use a base-64 encoded string and send it directly into the blob via ...
sfdcfox's user avatar
  • 481k
4 votes

Which special characters is not allowed when add new picklist value?

As far as I'm aware, only ; is diallowed; this is because, in SOQL, this character is used with INCLUDES and EXCLUDES to select values: SELECT Id FROM Account WHERE MultiIndustry__c IN ('A;B','C;D') ...
sfdcfox's user avatar
  • 481k
3 votes
Accepted

How to read/parse an X9.37 file via Apex?

Your example file is apparently in "EBCDIC" encoding. Apex only supports UTF-8, which EBCDIC is definitely not compatible with; EBCDIC is an IBM mainframe spec that is mostly a holdover from the days ...
sfdcfox's user avatar
  • 481k
3 votes
Accepted

Strings concatenation and one character size

Does not the '+=' concatenation create any additional string objects that devour your heap? Did not I miss anything? I am so amazed. The garbage collector (GC) is particularly aggressive, presumably ...
sfdcfox's user avatar
  • 481k
3 votes

Integer to ASCII conversion

Actually, the ASCII Code for the question mark character (?) is 63. system.assertEquals('?', String.fromCharArray(new List<Integer> { 63 })); Also, it does look like 5032 should correspond to ...
Adrian Larson's user avatar
  • 149k
3 votes

Convert application/octet-stream in E-mail Processing class

There are multiple things that can cause this behavior. 1) You might have set the email service to accept attachments in only 'Binary attachments only'. If you that is the case then your issue may ...
AtulRajguru9's user avatar
  • 9,110
3 votes
Accepted

JSON Serialize returning html entities that are not encoded

JSON is a protocol that is used for a large variety of purposes, not just for injecting HTML into a page; it's primary purpose is for scripting. As such, it doesn't know about, nor care about, ...
sfdcfox's user avatar
  • 481k
2 votes
Accepted

Error: Unrecognized base64 character

You try to decode the (supposedly) base64-encoded string key, somewhere halfway through the code. However, in your sample, the string is hardcoded to [my key], probably because you don't want to post ...
user254875486's user avatar
2 votes

Subject line Chinese Character issue in Salesforce

It seems that there is a problem with the encoding. Go to Setup->Communication Templates->Click on the Email Template and check if it is set to UTF-8 for the email template. Alternatively you ...
Marc Zaharescu's user avatar
2 votes
Accepted

Integer to ASCII conversion

In Java and Apex you are dealing with 16 bit characters (Unicode/UTF-16) not 8 bit characters (such as ASCII). Character 5032 in Unicode is this http://www.fileformat.info/info/unicode/char/5032/index....
Keith C's user avatar
  • 135k
2 votes
Accepted

Remove special character in javascript for a dynamic value

Apart from JavaScript, Visualforce has functions to escape special characters. You can use JSENCODE as: pageViewed('{!JSENCODE(currentName)} - Detail Page'); Additional encoding methods: HTMLENCODE ...
Raul's user avatar
  • 18.7k
2 votes

Retrieving VersionData with standard REST API

The problem was jQuery ajax method. Files should not be treated as strings. I solved the problem by leaving jQuery's ajax as I did not succeed to request a response type. By switching to plain JS and ...
Petr Vav's user avatar
2 votes

EROR: BLOB is not a valid UTF-8 string

Try this. You can't convert "BINARY" data into a String. A String only supports valid UTF-8 strings. Use EncodingUtil.Base64Encode if you need the binary data in a string you can work with. String ...
Avijit Chakraborty's user avatar
2 votes
Accepted

BLOB is not a valid UTF-8 string for JSON file inside Zipped Static resource

PageReference.forResource method used in your code gets the reference to the entire static resource (zip folder). In your case, you need to use the overloaded method documented here. Note that the ...
arut's user avatar
  • 5,246
2 votes
Accepted

Charset is set incorrectly to us-ascii instead of utf-8 when sending email from Marketing Cloud

If you look in the 'email overview' section that shows when you first click an email, you will notice in the left side, a small section titled 'Language'. This shows the currently set charset. If you ...
Gortonington's user avatar
  • 30.3k
2 votes
Accepted

Error: Incorrect parameter type for operator '+'. Expected Text, received Number

Wrapping the ROUND() output within a TEXT() is what you need here. + in this context expects appending two string values whereas ROUND() returns a number and thus the error. <apex:outputText value=...
Jayant Das's user avatar
  • 30.3k
1 vote

how to 'encode' the body in an HTTP body?

In Apex Code, \ is a source code escape character. That means to get a literal \, you need to type \\ instead. For this reason, among others, I always prefer to use JSON.serialize; it takes more code, ...
sfdcfox's user avatar
  • 481k
1 vote

Which special characters is not allowed when add new picklist value?

Given that semi-colon is not supported (for the reason given by sfdcfox) and all other UTF-8 are supported (AFAIK, including emojis), and if you really need a semi-colon Use ﹔ which is the UTF-8 ...
cropredy's user avatar
  • 69.9k
1 vote

Aura doesn't print <> combination of signs

This is expected behaviour in the sense that it sanitizes the output (based on the "Supported HTML Tags and attributes" at the help page): The component sanitizes HTML tags passed to the ...
Jeferson Chaves's user avatar
1 vote

How to force ANSI Encoding on a generated CSV attachement in apex?

You can't. Salesforce Apex always treats strings as UTF-8 and has no functionality for working with or converting between text encodings whatsoever. While you can implement gimmicky conversions in ...
David Reed's user avatar
  • 92.1k
1 vote

Handle Special characters like ° (degree)

Try changing the encoding of the file to UTF-8 This is the sf documentation on how to do it https://help.salesforce.com/articleView?id=000324657&type=1&mode=1 There is some good ...
PartOfTheOhana's user avatar
1 vote

Retrieving VersionData with standard REST API

The result is a binary blob. Appending it the way you did obviously results in garbled output, because you're looking at a raw set of bytes, not characters in a string. Given your current code, you ...
sfdcfox's user avatar
  • 481k
1 vote

EROR: BLOB is not a valid UTF-8 string

This code: System.debug(Blob.valueOf('abcéééxyz').toString()); runs fine. Suggest you examine the exact bytes that are sent to your end point.
Keith C's user avatar
  • 135k
1 vote
Accepted

Special characters in static resource

You can use default notepad in Windows to change the encoding to UTF-8. Please refer this Salesforce article describing how to change CSV encoding. But this is same for any text based files. Refere to ...
Saroj Bera's user avatar
  • 14.6k
1 vote

Integer to ASCII conversion

Essentially both your java and apex code are giving the right output. Java system.out.print to a console does not interpret the UTF-16 char, hence a "?". But now if you spool the char to a file(...
user40322's user avatar
  • 389
1 vote

Integer to ASCII conversion

In Apex Code and Java, strings are stored in UTF-8. The difference comes in the output of those characters (System.out vs System.debug). If you wrote the output to a file, and set the encoding to UTF-...
sfdcfox's user avatar
  • 481k
1 vote

decode Special Character in Angular + Visualforce

Use this for decode your url your_url = decodeURIComponent(your_url); your_url = decodeURI(your_url ); Use this for encode url your_url = encodeURIComponent(your_url); your_url = encodeURI(...
A.K.'s user avatar
  • 698

Only top scored, non community-wiki answers of a minimum length are eligible