Shortest self-analyzing program Oh, &lt;PROGRAM NAME HERE&gt;, tell me how many character '&lt;CHARACTER HERE&gt;'/s are there in your body.



I do not think it a dupe to this. That question asks for printing a list directly but this one requires some input that will cause problem.

Your work is to write a quine-like program/function that takes an input of one character, and respond with a number telling how many times that character occurs in your program. Comments, indents, trailing spaces, line feeds all count.

The range of acceptable input MUST cover all characters the language you are using can accept (not as string literals or comments) and all characters with lesser index in Unicode. For exmaple, Javascript and Python 3 accept Unicode characters for variable name, then it MUST allow Unicode input. For some stack processing languages, there are characters like ‘Ȯß, so part of the non-ASCII input MUST also be acceptable.

For example, if your program is in pure ASCII and only LF

foo(bar,baz)#there is a space-&gt; 
    do things


The inputs and outputs should be:


\n -> 1
\r -> 0
\t -> 0
 -> 9
a -> 4
b -> 2
( -> 1
) -> 1
\x01 through \x09 -> 0
＋(U+FF0B) -> undefined behaviour (you can even destroy everything or delete the program itself furiously)


The program with least characters wins.
Python, 172 chars
lambda a:'-mbda#l.fn()+1: \\\'i'.find(a)+1#\\\\\\\\\\\\\\((((((((())))))))))fffffffbd####lllll......nnnnnnnn+1+1+1+1+1+1+1+1+1+1+11:::::::::::::              '''''''''''''''iiiiiiiiiiiiiiiii

Using str.find()+1 to generate 0 for any character not in program.
Using comment for complement.