Is there an algorithm or technique to encrypt all the datatypes
Most encryption algorithms simply encrypt binary data, meaning they don't care what the data represents to the user. So, for example AES (under a suitable mode-of-operation depending on your actual use-case) would solve your question.
You mention in your clarification that someone has said an implementation that can encrypt any file will be more complicated than one that just encrypts a single file-type. This is not correct.
if I try to build such this algorithm ,what is the problems that may i face?
You would face lots of issues, for some of which see this. The short answer is making a crypto algorithm is very hard indeed, and lots of very experienced cryptographers have created schemes that turned out to have catastrophic security flaws.
The problem is that creating a 'new' encryption scheme is hard to do, and unless done very careful and tested incredibly thoroughly. For example, AES was tested through 3 years of competition, then 10 years of real-world-use. No matter how talented your crypto programmers are, if they try to generate their own schemes or implementations there is a high risk that something will be done incorrectly (such as a weakness in the scheme, or an implementation that is susceptible to side-channel attacks).
Much better would be to use a pre-built crypto library.
Interpreting your question in a different way, you might be interested in Format Preserving Encryption (FPE), which combines encryption with a reg-ex system such that the encryption of a file remains a valid file of the same format.