3 Answers
3

A basic SAN [Standard Algebraic Notation] move is given by listing the moving piece letter (omitted for pawns) followed by the destination square. Capture moves are denoted by the lower case letter "x" immediately prior to the destination square; pawn captures the file letter of the originating square of the capturing pawn immediately prior to the "x" character.

And

In the case of ambiguities (multiple pieces of the same type moving to the same square), the first appropriate disambiguating step of the three following steps is taken:

First, if the moving pieces can be distinguished by their originating files, the originating file letter of the moving piece is inserted immediately after the moving piece letter.

Second (when the first step fails), if the moving pieces can be distinguished by their originating ranks, the originating rank digit of the moving piece is inserted immediately after the moving piece letter.

Third (when both the first and the second steps fail), the two character square coordinate of the originating square of the moving piece is inserted immediately after the moving piece letter.

1: Rbb7

2: Rab7 or Rcb7

3: fxg5

4: hxg5

5: hxg6

6: Nac3

7: Nbc3 or Ndc3

Note that this is simply how the specification is written. En passant captures should not be an edge case, but they are unlikely to be implemented correctly 100% of the time. You'll have to test your replayer to see whether it handles these cases correctly or not.

is the 5 in ...xg5 necessary? pawns capture in only one way, there should be no problem with just ...xgedit: I just checked a major chess viewer/player and he uses the 5... Interesting
–
ajax333221Jan 10 '13 at 20:32

It is. I added the relevant section. There are no exceptions to the rule in the specification, and it's better to have a "hard" destination anyway. Again, keep in mind that not all replayers will implement this correctly.
–
Jonathan GarberJan 10 '13 at 20:37

true, the weird thing is that the specification just says "pawn captures the file letter of the originating square of the capturing pawn immediately prior to the "x" character.", never says anything about rank
–
ajax333221Jan 10 '13 at 20:40

Well, hmm, you're right. I think we can safely assume it's the correct way to disambiguate, but it's not in the specification. Granted, an ambiguous en passant capture IS an edge case in itself. But regardless, listing the destination is required by the spec in all cases.
–
Jonathan GarberJan 10 '13 at 20:43

1

One more random note, in #5, the correct pgn would be 1. hxg6. You can also add e.p. to create 1. hxg6 e.p. if you want to specify that the capture is en passant. But all pawn captures are origin file, "x", destination square.
–
Andrew♦Jan 10 '13 at 21:19